DTE2 Interface

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

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

Syntax

'Declaration
<GuidAttribute("2EE1E9FA-0AFE-4348-A89F-ED9CB45C99CF")> _
Public Interface DTE2 _
    Inherits _DTE
'Usage
Dim instance As DTE2
[GuidAttribute("2EE1E9FA-0AFE-4348-A89F-ED9CB45C99CF")]
public interface DTE2 : _DTE
[GuidAttribute(L"2EE1E9FA-0AFE-4348-A89F-ED9CB45C99CF")]
public interface class DTE2 : _DTE
public interface DTE2 extends _DTE

Remarks

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 Automation Assemblies and the DTE2 Object.

Examples

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

See Also

Reference

DTE2 Members

EnvDTE80 Namespace

Other Resources

Referencing Automation Assemblies and the DTE2 Object