DTE2.ActiveDocument 属性

定义

获取活动文档。

public:
 property EnvDTE::Document ^ ActiveDocument { EnvDTE::Document ^ get(); };
public:
 property EnvDTE::Document ^ ActiveDocument { EnvDTE::Document ^ get(); };
[System.Runtime.InteropServices.DispId(221)]
public EnvDTE.Document ActiveDocument { [System.Runtime.InteropServices.DispId(221)] get; }
[<System.Runtime.InteropServices.DispId(221)>]
[<get: System.Runtime.InteropServices.DispId(221)>]
member this.ActiveDocument : EnvDTE.Document
Public ReadOnly Property ActiveDocument As Document

属性值

Document

Document 对象。

实现

属性

示例

Sub ActiveDocumentExample()  
  Dim objTextDoc As TextDocument  
  Dim objEP As EditPoint  

  ' Create a new text document.  
  Call 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  

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

  Set doc = DTE2.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  

注解

活动文档是一个具有焦点的文档。 若要使另一个文档处于活动状态,请在其窗口上设置焦点。

只能在工具窗口上设置标题。 如果尝试在其他窗口类型(如文档窗口)上设置标题,会收到错误 "未指定的错误"。

适用于