VB.NET – Microsoft.Office.Interop.Word namespace alias is not identified

This is my code in Form1.vb:

Imports Word = Microsoft.Office.Interop.Word< br />
Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
< br /> Dim oWord As Word.Application
Dim oWord1 As Microsoft.Office.Interop.Word.Application
Dim oWord2 as Application

I am using VStudio2012 and Office 2010 and follow https://support.microsoft.com/kb/316383 sample to operate

The statement of oWord is marked by intellisense as “Type’Word.Application’ is not defined,
and oWord1 and oWord2 are accepted . Intellisense provides several error correction options-two of which I have tried (oWord1 and oWord2)-the other options don’t seem to apply.

In short, I am confused as to why naming is used in the Imports statement The spatial alias Word cannot satisfy the grammar Dim oWord As Word.Application, as described in the KB article. Is there some “master knob” that can be opened in the project properties dialog box?

You need to add a reference to import the DLL in this namespace. In Visual Studio 2012, right-click the project name in your Solution Explorer> Click “Add Reference”> select “Assembly”> “Extensions”> “Microsoft.Office.Interop.Word”. Interop Libraries may have multiple versions (Office 2003, 2007, 2010, etc.), please select Choose the appropriate version.

I believe that when you install Microsoft Office from the DVD, these assemblies will be installed initially. So you need to install Word I believe.

Edit: This works for me, using Intellisense:

Imports Word = Microsoft.Office.Interop.Word
Module Module1
Sub Main()
Dim oWord As Word.Application
End Sub
End Module

This is my code in Form1.vb:

Imports Word = Microsoft.Office.Interop.Word

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object , _
ByVal e As System.EventArgs) Handles Button1.Click

Dim oWord As Word.Application
Dim oWord1 As Microsoft.Office.Interop.Word.Application
Dim oWord2 as Application

I am using VStudio2012 and Office 2010, and follow the sample at https://support.microsoft.com/kb/316383

The statement of oWord is made by Intellisense is marked as “Type’Word.Application’ is not defined,
and oWord1 and oWord2 are accepted. Intellisense provides several error correction options-two of which I have tried (oWord1 and oWord2)-other options seem to be inapplicable.

In short, I am confused why the use of namespace alias Word in the Imports statement cannot satisfy the grammar Dim oWord As Word.Applicatio n, as described in the KB article. Are there some “main knobs” that can be opened in the project properties dialog box?

You need to add a reference to import the DLL of this namespace. In Visual Studio 2012, right-click on the project name in your solution explorer > Click “Add Reference”> select “Assembly”> “Extensions”> “Microsoft.Office.Interop.Word”. Interop Libraries may have multiple versions (Office 2003, 2007, 2010, etc.), please select the appropriate version.

I believe that when you install Microsoft Office from DVD, these assemblies will be installed initially. So you need to install Word I believe.

Edit: This works for me, Use Intellisense:

Imports Word = Microsoft.Office.Interop.Word
Module Module1
Sub Main()
Dim oWord As Word. Application
End Sub
End Module

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 3379 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.