I used to create a word-file from my application. It worked with Windows XP (Office 2003), but there's an error in Windows 7 (Office 2010).
If the word-application isn't open yet, I get the error "Call was rejected by callee (HRESULT: 0x80010001 (RPC_E_CALL_REJECTED))
I used to open the word application like this:
wordApp = (Microsoft.Office.Interop.Word.Application)Marshal.GetActiveObject("Word.Application");
wordApp = new Microsoft.Office.Interop.Word.Application();
wordApp.Visible = false;
then I found this link http://msdn.microsoft.com/en-us/library/ms228772(VS.80).aspx
and I changed the code to this
object obj = null;
System.Type t = null;
// Get the ProgID for DTE 8.0.
t = System.Type.GetTypeFromProgID("Word.Application", true);
// Create a new instance of the IDE.
obj = System.Activator.CreateInstance(t, true);
// Cast the instance to DTE2 and assign to variable dte.
dte = (EnvDTE80.DTE2)obj;
the last line, where I try to cast the word-application to EnvDTE80.DTE2 throws an exception (HRESULT: 0x80004002 (E_NOINTERFACE)). I don't know the message for this error, because I only see the german message.
Can anyone tell me please what I'm doing wrong?