Convert a Word.Application to EnvDTE80.DTE2

Posted on 2011-10-28
Last Modified: 2013-12-16
Hello everybody

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");
catch (COMException)
    wordApp = new Microsoft.Office.Interop.Word.Application();
    wordApp.Visible = false;

Open in new window

then I found this link 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;

Open in new window

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?

Thank you!
Question by:innovasoft
    LVL 15

    Accepted Solution

    Sample is for EnvDTE80.DTE2, it get a EnvDTE80.DTE2 object, then cast to EnvDTE80.DTE2.

    You Create a Word.Application, then you cast to Word.Application.
    LVL 1

    Author Comment

    omg sometimes it's scary what kind of mistakes I make ;) seems like i didn't really get what this DTE2 is standing for.

    Thank you!

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Suggested Solutions

    This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
    Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now