Window.Document プロパティ (Visio)
オブジェクトに関連付けられている Document オブジェクトを取得します。 読み取り専用です。
構文
式。ドキュメント
式Window オブジェクトを表す変数。
戻り値
Document
注釈
固定されたステンシル ウィンドウの Document プロパティは、ウィンドウの最前面に表示されているステンシルの Document オブジェクトを返します。 別のステンシルが最前面になると、元のステンシルの図面が閉じられ、その元のステンシルへの参照が無効になります。 つまり、固定されたステンシルへの図面参照は永続的でないことを考慮してください。
Window オブジェクトに開いているドキュメントが表示されない場合、ドキュメントは返されません。例外は発生しません。 Window オブジェクトの Document プロパティを取得した後に、Nothing が返されたかどうかを確認する必要があります。
例
次の Microsoft Visual Basic for Applications (VBA) マクロは、さまざまなオブジェクトの Document プロパティを使用して、これらのオブジェクトに関するデータを取得し、次の処理を行います。
Documents コレクションに Document オブジェクトを追加し、Document オブジェクトのプロパティを設定します。
アクティブなウィンドウとアクティブなページを取得し、このページに四角形を描画してから、作業対象となるさまざまなオブジェクトを提供するために Document オブジェクト上にマスター シェイプをドロップします。
Document プロパティを使用して、その他のオブジェクトそれぞれに関連付けられた Document オブジェクトを取得します。
Public Sub Document_Example()
Dim vsoDocument As Visio.Document
Dim vsoTempDocument As Visio.Document
Dim vsoPage As Visio.Page
Dim vsoShape As Visio.Shape
Dim vsoWindow As Visio.Window
Dim vsoMaster As Visio.Master
'Add a document to the Documents collection.
Set vsoDocument = Documents.Add("")
'Set the title of the document.
vsoDocument.Title = "My Document"
'Get the active window and active page.
Set vsoWindow = ActiveWindow
Set vsoPage = ActivePage
'Draw a rectangle on the page.
Set vsoShape = vsoPage.DrawRectangle(2, 2, 5, 5)
'Add a master.
Set vsoMaster = vsoDocument.Masters.Add
'Get the Document object associated with various other objects.'Get the Document object associated with the Window object.
Set vsoTempDocument = vsoWindow.Document
'Get the Title property of the Document object to verify that this is the same document we added earlier.
Debug.Print vsoTempDocument.Title
'Get the Document object associated with the Page object.
Set vsoTempDocument = vsoPage.Document
Debug.Print vsoTempDocument.Title
'Get the Document object associated with the Shape object.
Set vsoTempDocument = vsoShape.Document
Debug.Print vsoTempDocument.Title
'Get the Document object associated with the Master object.
Set vsoTempDocument = vsoMaster.Document
Debug.Print vsoTempDocument.Title
End Sub
サポートとフィードバック
Office VBA またはこの説明書に関するご質問やフィードバックがありますか? サポートの受け方およびフィードバックをお寄せいただく方法のガイダンスについては、Office VBA のサポートおよびフィードバックを参照してください。