共用方式為


Visio (的 Shape.Document 屬性)

取得與 物件相關聯的 Document 物件。 唯讀。

語法

運算式文檔

表達 代表 Shape 物件的變數。

傳回值

文件

範例

下列的 Microsoft Visual Basic for Applications (VBA) 巨集會示範如何使用不同物件的 Document 屬性來擷取這些物件的相關資料,並執行下列步驟:

  • 它會將 Document 物件新增到 Documents 集合,並設定數個 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 支援與意見反應