Skip to content

Latest commit

 

History

History
86 lines (50 loc) · 3.35 KB

Visio.GraphicItems.AddCopy.md

File metadata and controls

86 lines (50 loc) · 3.35 KB
title keywords f1_keywords api_name ms.assetid ms.date ms.localizationpriority
GraphicItems.AddCopy method (Visio)
vis_sdr.chm16860420
vis_sdr.chm16860420
Visio.GraphicItems.AddCopy
9956c5a5-8200-4e2a-c219-0a26fc40b414
06/08/2017
medium

GraphicItems.AddCopy method (Visio)

Adds a copy of a GraphicItem object to the GraphicItems collection of a Master object of type visTypeDataGraphic.

Note

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

Syntax

expression. AddCopy( _GraphicItem_ )

expression An expression that returns a GraphicItems object.

Parameters

Name Required/Optional Data type Description
GraphicItem Required [IVGRAPHICITEM] The GraphicItem object to copy.

Return value

GraphicItem

Remarks

The GraphicItem object you want to add must already exist in the GraphicItems collection of another Master object of type visTypeDataGraphic.

After you use the Master.Open to open a copy of a Master object of type visTypeDataGraphic for editing, you must use the Master.Close method to commit any changes you made to the master while it was open. Closing a copy of a data-graphic master also reapplies the data graphic to all shapes to which it was previously applied.

Note

For more information about why it is necessary to edit a copy of a master instead of the master itself, see Master.Open.

Example

The following Microsoft Visual Basic for Applications (VBA) macro shows how to use the AddCopy method to add a copy of an existing data-graphic item to the GraphicItems collection of a Master object.

The macro uses the Masters.AddEx method to add a new Master object of type visTypeDataGraphic to the Masters collection of the active document. Then, it uses the Master.Open method to get a copy of the new data graphic master to edit.

Next, the method gets a copy of an existing data-graphic item that is the first item in the GraphicItems collection of an existing master. Finally, it uses the AddCopy method to add the copy of the existing data-graphic item to the GraphicItems collection of the copy of the new master, and then closes the master copy.

The macro assumes that you know the name of the existing data-graphic master (" old_master_name ") that contains one or more graphic items you want to add to the new master. You can determine the name of an existing data graphic master by moving your mouse over the master in the Data Graphics task pane in the Visio user interface.

Public Sub AddCopy_Example() 
 
    Dim vsoMaster As Visio.Master 
    Dim vsoMasterCopy As Visio.Master 
    Dim vsoMaster_Old As Visio.Master 
    Dim vsoGraphicItem As GraphicItem 
    Dim vsoGraphicItem_Old As Visio.GraphicItem 
 
    Set vsoMaster = Visio.ActiveDocument.Masters.AddEx(visTypeDataGraphic) 
    Set vsoMasterCopy = vsoMaster.Open 
    Set vsoMaster_Old = ActiveDocument.Masters("old_master_name ") 
    Set vsoGraphicItem_Old = vsoMaster_Old.GraphicItems(1) 
    Set vsoGraphicItem = vsoMasterCopy.GraphicItems.AddCopy(vsoGraphicItem_Old) 
    vsoMasterCopy.Close     
 
End Sub

[!includeSupport and feedback]