DTE2.ActiveDocument 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取活动文档。
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 对象。
实现
- 属性
示例
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
注解
活动文档是一个具有焦点的文档。 若要使另一个文档处于活动状态,请在其窗口上设置焦点。
只能在工具窗口上设置标题。 如果尝试在其他窗口类型(如文档窗口)上设置标题,会收到错误 "未指定的错误"。