Problem to put the word host in an object: Word.Application

maitrepoy

New member
Joined
Jul 21, 2004
Messages
1
Im developping a simple VB.NET COM addin for office 2000, XP, 2003 on Windows 2000, XP, 2003. When Word is launched, the method OnStartupComplete (of my addin), tries to retrieve the Word application which is the host application and to place it in a variable wordApp, which type is: Word.Application.


Dim WithEvents WordApp As Word.Application

Public Sub OnStartupComplete(ByRef custom As System.Array) implements Extensibility.IDTExtensibility2.OnStartupComplete

(*) WordApp = applicationObject
try2 WordApp = DirectCast(applicationObject, Word.Application)
try3 WordApp = CType(applicationObject, Word.Application)

end sub

where applicationObject is a reference to the host Application.
But at this time: (*), an Exception is thrown: "Exception from HRESULT: 0x80040200", even with try2 and try3.

What is strange with this problem, is that it doesnt work on WinXP + OfficeXP, but on other OS and Office configurations, it properly works (eg: Win2000 + Office 2003)

Id like to add that I developped this addin with office 2003 and its libraries of objects: Microsoft Word 11.0 Object Library. version: 8.3. the file is: MSWORD.OLB.

Thanks in advance for helping a young trainee.
 
Last edited by a moderator:
Just a guess, but Id dont think that office libraries are not backward compatible. You developed the add-in with the Word 11.0 library, and when you try to run this on a machine using Office 2000/XP, its probably going to work, as it has an older version of the same library installed. However, I do believe the libraries are forward compatible (at least somewhat), so unless youre using stuff specific to Word 2003, you could probably just develop the add-in using an earlier version of Word/Office, and it should work with newer versions.
 
I do believe the libraries are forward compatible

Yes,this is correct ;)

If we intend to work with several version then its preferable to develop in the oldest version.

In general You may even consider to use late binding.

Kind regards,
Dennis
 
Back
Top