I wanted to remove a VBA Form in a Word template. The following is the code.
I have set the Word application property of "Trust Access from Visual Basic
Project", but it seems that the VBProject object I got is somehow invalid.
Dim wordApp As Microsoft.Office.Interop.Word.Application
Dim doc As Microsoft.Office.Interop.Word.Document
Dim vbProj As Microsoft.Vbe.Interop.VBProject
Dim name As String

wordApp = New Microsoft.Office.Interop.Word.Application
doc = wordApp.Documents.Open(FileName:="C:\\Temp\\Test.dot")
vbProj = doc.VBProject
name = vbProj.Name //This line throws exception

RE: Cannot access VBProject object by Adam

Adam
Mon May 12 12:05:03 PDT 2008

I figured out that the referenced "Microsoft.Vbe.Interop.dll" is of version
10 but my GAC is with 11.

"Adam" wrote:

> I wanted to remove a VBA Form in a Word template. The following is the code.
> I have set the Word application property of "Trust Access from Visual Basic
> Project", but it seems that the VBProject object I got is somehow invalid.
> Dim wordApp As Microsoft.Office.Interop.Word.Application
> Dim doc As Microsoft.Office.Interop.Word.Document
> Dim vbProj As Microsoft.Vbe.Interop.VBProject
> Dim name As String
>
> wordApp = New Microsoft.Office.Interop.Word.Application
> doc = wordApp.Documents.Open(FileName:="C:\\Temp\\Test.dot")
> vbProj = doc.VBProject
> name = vbProj.Name //This line throws exception
>
>