Document Interface

 

Represents a document in the environment open for editing.

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

[GuidAttribute("63EB5C39-CA8F-498E-9A66-6DD4A27AC95B")]
public interface Document

NameDescription
System_CAPS_pubpropertyActiveWindow

Gets the currently active window, or the topmost window if no others are active. Returns Nothing if no windows are open.

System_CAPS_pubpropertyCollection

Gets the collection containing the Document object.

System_CAPS_pubpropertyDTE

Gets the top-level extensibility object.

System_CAPS_pubpropertyExtender[String]

Returns the requested Extender if it is available for this object.

System_CAPS_pubpropertyExtenderCATID

Gets the Extender category ID (CATID) for the object.

System_CAPS_pubpropertyExtenderNames

Gets a list of available Extenders for the object.

System_CAPS_pubpropertyFullName

Gets the full path and name of the object's file.

System_CAPS_pubpropertyIndentSize

This API supports the product infrastructure and is not intended to be used directly from your code. Microsoft Internal Use Only.

System_CAPS_pubpropertyKind

Gets a GUID string indicating the kind or type of the object.

System_CAPS_pubpropertyLanguage

This API supports the product infrastructure and is not intended to be used directly from your code. Microsoft Internal Use Only.

System_CAPS_pubpropertyName

Gets the name of the Document.

System_CAPS_pubpropertyPath

Gets the path, without file name, for the directory containing the document.

System_CAPS_pubpropertyProjectItem

Gets the ProjectItem object associated with the Document object.

System_CAPS_pubpropertyReadOnly

This API supports the product infrastructure and is not intended to be used directly from your code. Microsoft Internal Use Only.

System_CAPS_pubpropertySaved

Returns true if the object has not been modified since last being saved or opened.

System_CAPS_pubpropertySelection

Gets an object representing the current selection on the Document.

System_CAPS_pubpropertyTabSize

This API supports the product infrastructure and is not intended to be used directly from your code. Microsoft Internal Use Only.

System_CAPS_pubpropertyType

This API supports the product infrastructure and is not intended to be used directly from your code. Microsoft Internal Use Only.

System_CAPS_pubpropertyWindows

Gets a Windows collection containing the windows that display in the object.

NameDescription
System_CAPS_pubmethodActivate()

Moves the focus to the current item.

System_CAPS_pubmethodClearBookmarks()

This API supports the product infrastructure and is not intended to be used directly from your code. Microsoft Internal Use Only.

System_CAPS_pubmethodClose(vsSaveChanges)

Closes the open document and optionally saves it, or closes and destroys the window.

System_CAPS_pubmethodMarkText(String, Int32)

This API supports the product infrastructure and is not intended to be used directly from your code. Microsoft Internal Use Only.

System_CAPS_pubmethodNewWindow()

Creates a new window in which to view the document.

System_CAPS_pubmethodObject(String)

Returns an interface or object that can be accessed at run time by name.

System_CAPS_pubmethodPrintOut()

This API supports the product infrastructure and is not intended to be used directly from your code. Microsoft Internal Use Only.

System_CAPS_pubmethodRedo()

Re-executes the last action that was undone by the Undo method or the user.

System_CAPS_pubmethodReplaceText(String, String, Int32)

This API supports the product infrastructure and is not intended to be used directly from your code. Microsoft Internal Use Only.

System_CAPS_pubmethodSave(String)

Saves the document.

System_CAPS_pubmethodUndo()

Reverses the action last performed by the user in the document.

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(...).

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
Return to top
Show: