共用方式為


DTE2.ActiveDocument 屬性

取得現用文件。

命名空間:  EnvDTE80
組件:  EnvDTE80 (在 EnvDTE80.dll 中)

語法

'宣告
ReadOnly Property ActiveDocument As Document
    Get
Document ActiveDocument { get; }
property Document^ ActiveDocument {
    Document^ get ();
}
abstract ActiveDocument : Document
function get ActiveDocument () : Document

屬性值

型別:EnvDTE.Document
Document 物件。

實作

_DTE.ActiveDocument

備註

現用文件就是取得焦點的文件。 若要讓另一文件成為作用中,請將焦點設定至它的視窗上。

您只能設定 [工具] 視窗上的標題。 如果您嘗試設定其他類型視窗的標題,例如 [文件] 視窗,則會發生「未指定的錯誤」。

範例

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

.NET Framework 安全性

請參閱

參考

DTE2 介面

ActiveDocument 多載

EnvDTE80 命名空間