Click to Rate and Give Feedback

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
Visual Studio Automation and Extensibility Reference
DTE Interface

The top-level object in the Visual Studio automation object model. Use this object for functionality and refer to _DTE for this object’s documentation.

Namespace:  EnvDTE
Assembly:  EnvDTE (in EnvDTE.dll)
Visual Basic (Declaration)
<GuidAttribute("04A72314-32E9-48E2-9B87-A63603454F3E")> _
Public Interface DTE _
    Implements _DTE
Visual Basic (Usage)
Dim instance As DTE
C#
[GuidAttribute("04A72314-32E9-48E2-9B87-A63603454F3E")]
public interface DTE : _DTE
Visual C++
[GuidAttribute(L"04A72314-32E9-48E2-9B87-A63603454F3E")]
public interface class DTE : _DTE
JScript
public interface DTE extends _DTE

The DTE object is provided 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 Automation Assemblies and the DTE2 Object.

Visual Basic
Sub DTEExample()
    Dim objTextDoc As TextDocument
    Dim objEP As EditPoint
    
    ' Create a new text document.
    DTE.ItemOperations.NewFile("General\Text File")
    ' Get a handle to the new document.
    Set objTextDoc = DTE.ActiveDocument.Object("TextDocument")
    Set objEP = objTextDoc.StartPoint.CreateEditPoint
    ' Create an EditPoint and add some text.
    objEP.Insert "A test sentence."
End Sub
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker