Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
DTE2 Interface
Collapse the table of content
Expand the table of content

DTE2 Interface 

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

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

public interface DTE2 : _DTE
/** @attribute GuidAttribute("2EE1E9FA-0AFE-4348-A89F-ED9CB45C99CF") */ 
public interface DTE2 extends _DTE
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
© 2015 Microsoft