I want to be able to update shape masters with some code, specifically shape text. What I have is the following, which results in the Master text displaying [Obj], instead of the shape text from the source. A Google search hasn't found me results, yet. What's going wrong?
Dim mstr As Visio.Master
Dim mstrCopy As Visio.Master
Dim shp As Visio.Shape
Dim shpMaster As Visio.Shape
Set shp = ActiveWindow.Selection(1)
Set mstr = shp.Master
'How to detect if open, and close, or error out?
Set mstrCopy = mstr.Open
Set shpMaster = mstrCopy.Shapes(1) 'Set the shape to the first shape in the master
shpMaster.Text = shp.Text
mstCopy.Close
i tested this code, it works
Dim mstrName As String
Dim mstrCopy As Visio.Master
Dim shp As Visio.Shape
Dim shpMaster As Visio.Shape
Dim mstrWin As Window
Set shp = ActiveWindow.Selection(1)
mstrName = shp.Master.NameU ' get selected shape master name
'How to detect if open, and close, or error out?
Set mstrCopy = ActiveDocument.Masters.ItemU(mstrName) '
Set mstrWin = mstrCopy.OpenDrawWindow ' open masters window
Set shpMaster = mstrCopy.Shapes(1) 'Set the shape to the first shape in the master
shpMaster.Text = shp.Text
mstrWin.Close ' close master window
Thanks. As it turns out, I think I broke the link between the shapes, somehow. When I searched for the parent, it found the parent, apparently, and updated in the manner I mentioned. However, I noticed shape data was not synchronizing, so I re-dropped the shapes from the template. After that, it worked.