This documentation is archived and is not being maintained.

Document Object

Visual Studio .NET 2003

Represents a document in the environment open for editing.




[Visual Basic .NET]
Public Interface Document
    Inherits IDispatch
[Visual Basic 6]
Class Document
interface Document : IDispatch
public interface Document : IDispatch
[JScript .NET]
public interface Document extends IDispatch


A Document object represents each open document or designer in the environmentthat 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 using DTE.Documents.Item().


Namespace: EnvDTE

File: dte.tlb


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"
    desc = desc & "writable"
  End If
  desc = desc & " document called " & doc.Name & " located at " & doc.Path
  MsgBox desc
End Sub

See Also

Documents Collection | TextDocument Object

Properties, Methods, and Events