Open method (Master object)

Microsoft Visio Developer Reference

Open method (Master object)

   Example   

Opens an existing master so it can be edited.

Version added

4.1

Syntax

masterObjCopy = masterObj.Open

masterObjCopy

A temporary copy of masterObj.

masterObj

Required. An expression that returns a Master object to be edited.

Remarks

You can use the Open method for a Master object in conjunction with the Close method to reliably edit the shapes and cells of a master. In previous versions of Visio, you could edit a Master object's shapes and cells, but the changes weren't pushed to instances of the master, and alignment box information displayed when instancing the edited master wasn't correct.

To edit the shapes and cells of a Master object from a program, follow these steps:

  1. Open the Master object for editing using masterObjCopy = masterObj.Open. This code fails if there is a drawing window open into masterObj or if other programs already have masterObj open. If the Open method succeeds, masterObjCopy is a copy of masterObj.
  1. Change any shapes and cells in masterObjCopy, not masterObj.
  1. Close the Master object using masterObjCopy.Close. The Close method fails if masterObjCopy isn't a Master object that resulted from a prior masterObj.Open call. Otherwise, the Close method merges the changes made in step 2 from masterObjCopy back into masterObj. It also updates all instances of masterObj to reflect the changes and update information cached in masterObj. If masterObj.IconUpdate isn't visManual (0), the Close method updates the icon shown in the stencil window for masterObj to depict an image of masterObjCopy.

If you change the shapes and cells of a master directly, as opposed to opening and closing the master as described in the procedure above, the effects listed in step 3 don't occur.

A program that creates a copy of a masterObj for editing should both close and release the copy. Microsoft Visual Basic typically releases it automatically. However, with C/C++, you must explicitly release the copy, just as you would for any other object.