Export (0) Print
Expand All

DTE2 Interface 

The top-level object in the Visual Studio automation object model.

Namespace: EnvDTE80
Assembly: EnvDTE80 (in envdte80.dll)

[GuidAttribute("2EE1E9FA-0AFE-4348-A89F-ED9CB45C99CF")] 
public interface DTE2 : _DTE
/** @attribute GuidAttribute("2EE1E9FA-0AFE-4348-A89F-ED9CB45C99CF") */ 
public interface DTE2 extends _DTE
GuidAttribute("2EE1E9FA-0AFE-4348-A89F-ED9CB45C99CF") 
public interface DTE2 extends _DTE

The DTE object is provided to you by the OnConnection method that you implement when you create an Add-in. The DTE object is the Application object in Visual Basic.

To access project-specific properties such as VBProjects or CSharpProjects, use the syntax DTE.GetObject("VBProjects").

For details about referencing the EnvDTE namespace and the DTE object, see Referencing the DTE Object.

Sub DTEExample()
  Dim objTextDoc As TextDocument
  Dim objEP As EditPoint
  
  'Create a new text document.
  DTE2.ItemOperations.NewFile("General\Text File")
  'Get a handle to the new document.
  Set objTextDoc = DTE2.ActiveDocument.Object("TextDocument")
  Set objEP = objTextDoc.StartPoint.CreateEditPoint
  'Create an EditPoint and add some text.
  objEP.Insert "A test sentence."
End Sub
Show:
© 2014 Microsoft