locked
Opening a document from an add-in RRS feed

  • Question

  • Hi,

    I'm a bit new to add-in development, so I don't know if this is a stupid question: how do I open a document from an add-in?  The DTE2 object has an OpenFile member that's marked as "for microsoft internal use only" and I'm not sure where else to look.

    Thanks in advance for your help,

    Ben.
    Monday, November 28, 2005 4:50 PM

Answers

  • You can try the following where dte is a DTE object:

    EnvDTE.Window window = dte.ItemOperations.OpenFile(this.sourceDocument, EnvDTE.Constants.vsViewKindCode);

    window.Activate();
    window.SetFocus();

    Monday, November 28, 2005 9:45 PM

All replies

  • Check out the SDK Documentation under:

    IVsProject3.OpenItem Method, it specifies how to open a file using a project-specific or global editor.
     

    I'm not sure if this helps, depending on how specific you're looking into opening a doc.  If its a simple text document, or a text-like document that you want to invoke then check out the SDK documentation under:  "Working with the Core Editor" under the "Editors" topic in the "How do I" tab.  There are a couple of samples and walkthroughs here as well.

    Hope this helps.  
    Monday, November 28, 2005 7:31 PM
  • You can try the following where dte is a DTE object:

    EnvDTE.Window window = dte.ItemOperations.OpenFile(this.sourceDocument, EnvDTE.Constants.vsViewKindCode);

    window.Activate();
    window.SetFocus();

    Monday, November 28, 2005 9:45 PM
  • Brilliant, the dte.ItemOperations thing sorted it nicely.  couldn't find the IvsProject3 thing in time... :)

    Great forum by the way - actual helpful people in it!

    Thanks guys,

    Ben.
    Tuesday, November 29, 2005 10:43 AM