By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,830 Members | 1,758 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,830 IT Pros & Developers. It's quick & easy.

Installation of program that uses Microsoft.Office.Interop

P: n/a
I have created a program that allows for the automation of things in Word
documents, like changing the values of DocVariables and the links to Excel
Sheets. I did it using interoperoperatability, where, after adding a
reference to Microsoft.Office.Core and a reference to Microsoft Word I
declare objects as follows:

Dim oWordApp As New Microsoft.Office.Interop.Word.Application, .

Everything works fine on the development computer (Office 2003 is in use
here). But when I install the program on a computer running Windows ME
(Office 2002 in use here), the following happens.

1. The program opens fine. I am also able to start an instance of
Microsoft Word via the program, but when I attempt to open a specific
document with Word I get the error: "Object reference not set to an
instance of an object."
Dim docPath As New Object
Me.OpenFileDialog1.Filter = "Word files (*.doc)|*.doc"
If Me.OpenFileDialog1.ShowDialog() = DialogResult.OK Then
docPath = Me.OpenFileDialog1.FileName
End If
oWordApp.Visible = True
oWordApp.Documents.Open(docPath) 'Error occurs here
As a point of information, the following DLL's are installed in the
Application folder by the installation:

Interop. Microsoft.Office.Core.dll
Microsoft.Ofifice.Infterop.Excel.dll
Microsoft.Ofifice.Infterop.Word.dll
Microsoft.Vbe.Interop.dll
office.dll
stdole.dll

Is there a problem with using these DLLs above generated by Visual Studio?
I read this at Microsoft:

"You must also avoid the use of any Office XP COM interop assembly that is
generated by Microsoft Visual Studio .NET at design time. Any Office XP
interop assembly that is not included in the Office XP PIAs download is
considered unofficial."
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi,

You must either require the user have the same version of office
or use late binding.

Ken
----------------
"William LaMartin" <la******@tampabay.rr.com> wrote in message
news:e9*************@TK2MSFTNGP12.phx.gbl...
I have created a program that allows for the automation of things in Word
documents, like changing the values of DocVariables and the links to Excel
Sheets. I did it using interoperoperatability, where, after adding a
reference to Microsoft.Office.Core and a reference to Microsoft Word I
declare objects as follows:

Dim oWordApp As New Microsoft.Office.Interop.Word.Application, .

Everything works fine on the development computer (Office 2003 is in use
here). But when I install the program on a computer running Windows ME
(Office 2002 in use here), the following happens.

1. The program opens fine. I am also able to start an instance of
Microsoft Word via the program, but when I attempt to open a specific
document with Word I get the error: "Object reference not set to an
instance of an object."
Dim docPath As New Object
Me.OpenFileDialog1.Filter = "Word files (*.doc)|*.doc"
If Me.OpenFileDialog1.ShowDialog() = DialogResult.OK Then
docPath = Me.OpenFileDialog1.FileName
End If
oWordApp.Visible = True
oWordApp.Documents.Open(docPath) 'Error occurs here
As a point of information, the following DLL's are installed in the
Application folder by the installation:

Interop. Microsoft.Office.Core.dll
Microsoft.Ofifice.Infterop.Excel.dll
Microsoft.Ofifice.Infterop.Word.dll
Microsoft.Vbe.Interop.dll
office.dll
stdole.dll

Is there a problem with using these DLLs above generated by Visual Studio?
I read this at Microsoft:

"You must also avoid the use of any Office XP COM interop assembly that is
generated by Microsoft Visual Studio .NET at design time. Any Office XP
interop assembly that is not included in the Office XP PIAs download is
considered unofficial."

Nov 21 '05 #2

P: n/a
Thanks.

By adding Option Strict Off to the top of my code page and using the code
below, I can now create a VB.Net program that when installed on a computer
running a different version of Office than was installed on the development
computer (Office 2003), have it start Word and open a document.

Unfortunately when I create the Word object WordApp this way I loose the
intellisense for it. Is there a way to regain this for the object? Or must
I write the code using Microsoft.Office.Interop.Word.ApplicationClass so as
to have the iltellisense available for creating the code, and then remove
all instances of that and revert to the type of code below to actually use
it on other computers?

Dim WordApp As New Object
WordApp = CreateObject("Word.Application")
Dim docPath As String
Me.OpenFileDialog1.Filter = "Word files (*.doc)|*.doc"
If Me.OpenFileDialog1.ShowDialog() = DialogResult.OK Then
docPath = Me.OpenFileDialog1.FileName
End If
WordApp.Visible = True
WordApp.Documents.Open(docPath)

"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:uc*************@tk2msftngp13.phx.gbl...
Hi,

You must either require the user have the same version of office or use late binding.

Ken
----------------
"William LaMartin" <la******@tampabay.rr.com> wrote in message
news:e9*************@TK2MSFTNGP12.phx.gbl...
I have created a program that allows for the automation of things in Word
documents, like changing the values of DocVariables and the links to Excel
Sheets. I did it using interoperoperatability, where, after adding a
reference to Microsoft.Office.Core and a reference to Microsoft Word I
declare objects as follows:

Dim oWordApp As New Microsoft.Office.Interop.Word.Application, .

Everything works fine on the development computer (Office 2003 is in use
here). But when I install the program on a computer running Windows ME
(Office 2002 in use here), the following happens.

1. The program opens fine. I am also able to start an instance of
Microsoft Word via the program, but when I attempt to open a specific
document with Word I get the error: "Object reference not set to an
instance of an object."
Dim docPath As New Object
Me.OpenFileDialog1.Filter = "Word files (*.doc)|*.doc"
If Me.OpenFileDialog1.ShowDialog() = DialogResult.OK Then
docPath = Me.OpenFileDialog1.FileName
End If
oWordApp.Visible = True
oWordApp.Documents.Open(docPath) 'Error occurs here
As a point of information, the following DLL's are installed in the
Application folder by the installation:

Interop. Microsoft.Office.Core.dll
Microsoft.Ofifice.Infterop.Excel.dll
Microsoft.Ofifice.Infterop.Word.dll
Microsoft.Vbe.Interop.dll
office.dll
stdole.dll

Is there a problem with using these DLLs above generated by Visual Studio?
I read this at Microsoft:

"You must also avoid the use of any Office XP COM interop assembly that is
generated by Microsoft Visual Studio .NET at design time. Any Office XP
interop assembly that is not included in the Office XP PIAs download is
considered unofficial."

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.