I'm 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.

VB Code:
  1. Dim WithEvents WordApp As Word.Application
  2.  
  3.              Public Sub OnStartupComplete(ByRef custom As System.Array) implements Extensibility.IDTExtensibility2.OnStartupComplete
  4.  
  5.  (*)          WordApp = applicationObject
  6. ' try2        WordApp = DirectCast(applicationObject, Word.Application)
  7. ' try3        WordApp = CType(applicationObject, Word.Application)
  8.  
  9.             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 doesn't work on WinXP + OfficeXP, but on other OS and Office configurations, it properly works (eg: Win2000 + Office 2003)

Thanks in advance for helping a young trainee.