Site icon bVisual

The Hidden Master Cells – ShapeKeywords and Copyright

Readers of my blog will know that I often customize Visio masters, but I rarely bother to (re-)set the keywords or copyright. The reason being that I do not like to change the copyright if it has been set by another, and I was not quite sure where the keywords were stored. So, I decided to document them both here for my (and your) future use!

 

Master Keywords

The Keywords textbox on the Master Properties dialog provides you with the opportunity to enter keywords for the master which can be used by the Search function:

However, if you look at the properties of the Master object, you will not find a Keywords property:

This is because these keywords are not stored against the master object, but are actually stored in a cell, called ShapeKeywords, in the page of the Master!

Try it for yourself by typing something like the following in the Immediate Window:

?Visio.ActiveDocument.Masters(1).Name
Process
?Visio.ActiveDocument.Masters(1).PageSheet.Cells("ShapeKeywords").ResultStr("")
Process,function,procedure,action,task,basic,flowchart,flow,data,business,six,6,sigma,iSO,9000

 

Surprising, huh?

This cell does not appear in the ShapeSheet window…

Shape Copyright

I was always taught that the Copyright is a write once operation, and indeed that is true if you try to automate it. If you look at the the master shape of a Microsoft supplied master, then you will find the Copyright is read-only:

If you draw your own shapes, then the copyright cell is available to edit … until you save it!

It is indeed a write once cell, because the next time you open the Shape Name dialog, the Copyright textbox will be greyed out.

In the VBA Immediate Window, you get read the copyright like this:

?Visio.ActiveWindow.Selection.PrimaryItem.Cells("Copyright").ResultStr("")
Here is my own copyright message!

But, if you then tried to overwrite it, you will get an error message:

Visio.ActiveWindow.Selection.PrimaryItem.Cells("Copyright").Formula = "=""Oops, I meant to write this!"""

Not surprisingly, this cell does not appear in the ShapeSheet window either…

 

Hiding Information in your Pages

So, knowing that the ShapeKeywords cell is in the PageSheet of a Master, then it follows that it exists in every page. It is perhaps more surprising that the Copyright cell also exists in every page.

Therefore we have two hidden cells that you can address in the ShapeSheet, as in this example Shape Data section:

=GUARD(ThePage!ShapeKeywords)

=GUARD(ThePage!Copyright)

You could set the ShapeKeywords cell value in code:

Visio.ActivePage.PageSheet.Cells("ShapeKeywords").Formula = "=""Be smart, be clear, BE VISUAL"""

Visio.ActivePage.PageSheet.Cells("Copyright").Formula = "=""bVisual ltd"""

Then, any shape can read the values:

 

It can get a bit tedious to do that an every page, so you could put a SETF() formula into the EventDrop cell of a shape:

=SETF(GetRef(ThePage!Copyright),"=""bVisual ltd""")

There is no error if the Copyright cell is written to again … it just fails. Therefore the first set of the page Copyright cell wins.

The ShapeKeywords cell, on the other hand, can be written to many times.

I am not sure what use I will put this knowledge too, but I thought I would write them down for others to ponder….

Exit mobile version