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 名前空間