Visio) (GraphicItem.Delete 方法

會從 visTypeDataGraphic 類型之 Master 物件的 GraphicItems 集合中刪除 GraphicItem 物件。

注意事項

This Visio object or member is available only to licensed users of Visio Professional 2013.

語法

運算式。刪除

運算式 代表 GraphicItem 物件的變數。

傳回值

無

註解

在您可以刪除圖形項目之前,您必須使用 Master.Open 方法開啟以編輯圖形項目所屬之 GraphicItems 集合的資料圖形主機複本。 當您刪除該圖形項目,並進行您想要的任何其他編輯之後,請使用 Master.Close 方法確認變更。

範例

下列Microsoft Visual Basic for Applications (VBA) 巨集 示範如何使用 Delete 方法從 Master 物件的 GraphicItems 集合中刪除現有的圖形項目。 它會刪除最近新增至集合的圖形項目,並將刪除之前和之後的主複本集合中的圖形項目計數列印到 [立即] 視窗。 關閉主複本之後,也會列印主複本本身集合中的圖形項目計數,以顯示對複本執行的動作已認可至主複本。

巨集會假設專案中存在現有的資料圖形主機,其 GraphicItems 集合至少有一個成員。 您可以將滑鼠指標移到 Visio 使用者介面中 [資料圖形] 工作窗格內的主圖形上方,以判斷現有資料圖形主圖形的名稱。 此範例中的主控片名為 “Data Graphic”。

Public Sub Delete_Example() 
 
    Dim vsoMaster As Visio.Master 
    Dim vsoMasterCopy As Visio.Master 
    Dim intGraphicItemCount As Integer 
 
    Set vsoMaster = ActiveDocument.Masters("Data Graphic") 
    Set vsoMasterCopy = vsoMaster.Open 
     
    intGraphicItemCount = vsoMasterCopy.GraphicItems.Count 
     
    Debug.Print "Before delete", intGraphicItemCount 
    vsoMasterCopy.GraphicItems(intGraphicItemCount).Delete 
    Debug.Print "After delete", vsoMasterCopy.GraphicItems.Count 
    vsoMasterCopy.Close 
    Debug.Print "After close", vsoMaster.GraphicItems.Count 
     
End Sub

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應。