Udostępnij za pośrednictwem


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
[GuidAttribute("63EB5C39-CA8F-498E-9A66-6DD4A27AC95B")]
public interface Document
[GuidAttribute(L"63EB5C39-CA8F-498E-9A66-6DD4A27AC95B")]
public interface class Document
[<GuidAttribute("63EB5C39-CA8F-498E-9A66-6DD4A27AC95B")>]
type Document =  interface end
public interface Document

The Document type exposes the following members.

Properties

  Name Description
Public property ActiveWindow Gets the currently active window, or the topmost window if no others are active. Returns Nothing if no windows are open.
Public property Collection Gets the collection containing the Document object.
Public property DTE Gets the top-level extensibility object.
Public property Extender Returns the requested Extender if it is available for this object.
Public property ExtenderCATID Gets the Extender category ID (CATID) for the object.
Public property ExtenderNames Gets a list of available Extenders for the object.
Public property FullName Gets the full path and name of the object's file.
Public property IndentSize Infrastructure. Microsoft Internal Use Only.
Public property Kind Gets a GUID string indicating the kind or type of the object.
Public property Language Infrastructure. Microsoft Internal Use Only.
Public property Name Gets the name of the Document.
Public property Path Gets the path, without file name, for the directory containing the document.
Public property ProjectItem Gets the ProjectItem object associated with the Document object.
Public property ReadOnly Infrastructure. Microsoft Internal Use Only.
Public property Saved Returns true if the object has not been modified since last being saved or opened.
Public property Selection Gets an object representing the current selection on the Document.
Public property TabSize Infrastructure. Microsoft Internal Use Only.
Public property Type Infrastructure. Microsoft Internal Use Only.
Public property Windows Gets a Windows collection containing the windows that display in the object.

Top

Methods

  Name Description
Public method Activate Moves the focus to the current item.
Public method ClearBookmarks Infrastructure. Microsoft Internal Use Only.
Public method Close Closes the open document and optionally saves it, or closes and destroys the window.
Public method MarkText Infrastructure. Microsoft Internal Use Only.
Public method NewWindow Creates a new window in which to view the document.
Public method Object Returns an interface or object that can be accessed at run time by name.
Public method PrintOut Infrastructure. Microsoft Internal Use Only.
Public method Redo Re-executes the last action that was undone by the Undo method or the user.
Public method ReplaceText Infrastructure. Microsoft Internal Use Only.
Public method Save Saves the document.
Public method Undo Reverses the action last performed by the user in the document.

Top

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

EnvDTE Namespace