Share via


Clone Property [Visio 2003 SDK Documentation]

Returns a copy of the UIObject object.

objRet = object**.Clone**

objRet     A copy of the UIObject object.

object     Required. An expression that returns a UIObject object.

Version added

2000

Example

This example shows how to use the Clone property to make a copy of a UIObject object. The example adds a custom toolbar to the cloned toolbars collection. This toolbar appears in the Microsoft Office Visio user interface and is available while the document is active.

To restore the built-in toolbars in Microsoft Office Visio after you run this macro, call the ThisDocument.ClearCustomToolbars method.

Sub Clone_Example()
 
    Dim vsoUIObject As Visio.UIObject 
    Dim vsoToolbars As Visio.Toolbars 
    Dim vsoToolbar As Visio.Toolbar 

    'Check whether there are document custom toolbars.
    If ThisDocument.CustomToolbars Is Nothing Then

        'Check whether there are application custom toolbars.
        If Visio.Application.CustomToolbars Is Nothing Then

            'Use the built-in toolbars.
            Set vsoUIObject = Visio.Application.BuiltInToolbars(0) 

        Else

            'Use the application custom toolbars.
            Set vsoUIObject = Visio.Application.CustomToolbars.Clone
 
        End If

  
    Else

        'Use the document custom toolbars.
        Set vsoUIObject = ThisDocument.CustomToolbars 

    End If  

    'Get the Toolbars collection for the drawing window context.
    Set vsoToolbars = vsoUIObject.ToolbarSets.ItemAtID(Visio.visUIObjSetDrawing).Toolbars 

    'Add a toolbar to the collection.
    Set vsoToolbar = vsoToolbars.Add 

    'Set the title of the toolbar. 
    vsoToolbar.Caption = "My New Toolbar" 

    'Tell Visio to use the new UIObject object while
    'this document is active. 
    ThisDocument.SetCustomToolbars vsoUIObject 

End Sub

Applies to | UIObject object