Share via


Document Interface

Represents a document in the environment open for editing.

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

Syntax

'Declaration
<GuidAttribute("63EB5C39-CA8F-498E-9A66-6DD4A27AC95B")> _
Public Interface Document
'Usage
Dim instance As Document
[GuidAttribute("63EB5C39-CA8F-498E-9A66-6DD4A27AC95B")]
public interface Document
[GuidAttribute(L"63EB5C39-CA8F-498E-9A66-6DD4A27AC95B")]
public interface class Document
public interface Document

Remarks

A Document object represents each open document or designer in the environment — that is, windows that are not tool windows and have an area to edit text. The Document object has members (properties, methods, and events) that you can use to manipulate the document. If it is a text file edited by the Visual Studio editor, then it also has a TextDocument object associated with it.

All open documents are referenced in the Documents collection. You can find a particular document by iterating through this collection.

The default property for a Document object is the Name property.

Reference this object by using DTE.Documents.Item(...).

Examples

Sub DocumentExample()
    Dim doc As Document
    Dim desc As String

    Set doc = DTE.ActiveDocument
    desc = "You are editing a "
    If (doc.ReadOnly) Then
        desc = desc & "read-only"
    Else
        desc = desc & "writable"
    End If
    desc = desc & " document called " & doc.Name & " located at " & doc.Path
    MsgBox desc
End Sub

See Also

Reference

Document Members

EnvDTE Namespace