How to modify or change description (legend description) of shape in Visio 2010

Started by jel888, March 13, 2012, 12:01:05 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jel888

Hello,

Somewhat new to Visio (that is I've been using it as a basic level user since it's earliect forms, but am now try to advance my skills some) and would like to know how to modify the "description" of a shape (that is the one that shows up after you put a shape in a legend shape.

To further explain, I've created a Master shape in my own stencil that I took for another stencil.  It was a site or subsite shape and before I added it to my stencil, I changed the image (I simply deleted the text under the image) and dropped it to my stencil and changed "Master.XX" to "Site ou sous-site" (I'm in a French version of Visio 2010).  The name takes, but when I add the shape to a legend (the auto legend shape), the "description" column in the legend shows 'Site our sous_site.22" as the name, not the actual name or description I typed next to the shape before moving it into my stencil.

The weird thing is that the first time I made this shape (without modifying the text under the image), it didn't do this when I changed the name.

Any insight on why this happens and how to fix this?

Thanks!

Bogardo

I have the same problem. Can somebody give a good solution? I read something about changing the universal name of the shape...

Fin311

The problem resides in the document stencil.  It pulls the master name from that stencil... For example you drag a master from stencil A.  This master now resides in the doc stencil, but when you drag the same shape from stencil A visio creates a second master in the doc stencil with shape.##. This confuses the legend shape, now you have two masters with identical names, but the legend will find the most current shape i.e. shape.##. If you have visio 10 you can manually change the text in the legend by double clicking the text and typing any info you would like. Because the legend is essentially a container shape with lists.

Bogardo

Quote from: Fin311 on March 28, 2012, 11:31:50 PM
The problem resides in the document stencil.  It pulls the master name from that stencil... For example you drag a master from stencil A.  This master now resides in the doc stencil, but when you drag the same shape from stencil A visio creates a second master in the doc stencil with shape.##. This confuses the legend shape, now you have two masters with identical names, but the legend will find the most current shape i.e. shape.##. If you have visio 10 you can manually change the text in the legend by double clicking the text and typing any info you would like. Because the legend is essentially a container shape with lists.

Manually change the name in the legend is an option but not a practical one. You want the legend to be perfect without changing anything.
I think I'm going to make a new template when al my shapes are done and import the stencils into the new document. In this way, al master names are good.

safewithyou247

So after a lot of trial and error, I was able to figure out what was going on with this issue. At first, I was looking and NameU but that never panned out. Then I looked at the Stencils because the issue always seemed to come from there. When I could not fix the issue, I started digging through multiple areas that I thought it could be and then finally I found out where the issue is. The issue is with the Masters Array of the Document that you are editing. I decided just to clear out all the items in the array. Once you do this, some items will come right back, but they normally don't after the second time.

Here is the code that I used. It is very crude, but it can be modified to do whatever you are needing. I have used it about 5 times now and it seems to work without an issue.


Sub DeleteMasters()
   
    Dim visDoc As Visio.Document
    Set visDoc = Application.ActiveDocument
    Dim visMasters As Visio.Masters
    Set visMasters = visDoc.Masters
    Dim visMaster As Visio.Master

    For Each visMaster In visMasters
            visMaster.Delete
    Next visMaster
   
    If visMasters.Count > 0 Then
   
    For Each visMaster In visMasters
            visMaster.Delete
    Next visMaster
   
    End If
   

End Sub


Please let me know if this works for you.

Paul Herber

If Linus Torvalds saw this code he'd have a really good rant and with good reason!
Sorry, but please don't write code like that. Deleting the masters is not a solution. Your code doesn't delete them all anyway.

Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

safewithyou247

Hey Paul,

I am not sure who you are referring to, but this issue is a very real one and I have been frustrated by it for months. This is the only way that I was able to get the legend to display the correct name of my Master.

The issue is that if you create a stencil and create a master named "Link" and then you drag it onto your drawing, the drawing keeps that master in record even once it has been deleted from your document. If you correct an issue with the master and then drag it back onto the drawing, you get a name like "Link.##". This is not apparent in most situations, but it is when you are using the "Legend" master. This Master looks at the name of each Shape that is defined as a symbol and populates the table. You cannot edit this name in the table and it is very frustrating to fix it.

The code example that I gave was only for directional purposes. When I used the code, I wrote qualifiers for the exact masters that I wanted to delete. These masters no longer existed in my drawing but still existed in the Masters array. I considered creating a more elaborate code with a user form that displayed all the items in the array and then allow the user to select what they wanted to delete, but I figured that it was to much work, as I expect people to taylor this to their needs.

Sorry for any confusion that I may have caused, and I hope this clears it up.

wapperdude

Deleting masters from document stencil ought to be a built-in capability of Visio.  Over the course of creating a drawing, it does indeed get littered with the corpses of unused shapes. 

David Parker wrote a macro to address t his issue, plus tidy up the file in general.  His baseline was V2010.  Here's the reference link:  https://blog.bvisual.net/2015/01/07/cleaning-visio-documents/

For V2007 and earlier users, this link will be of interest:  http://www.visiozone.com/?p=66

Regarding the code:  I believe this might be useful for this task:  http://www.office-forums.com/threads/remove-extra-shapes-from-master-document-stencil.1618208/

HTH
Wapperdude

Visio 2019 Pro

safewithyou247

Wow! Thanks for that great post. I had no idea you could do this. So there is a function that cleans all unused masters from a document.


Visio.ActiveDocument.RemoveHiddenInformation visRHIMasters


Conversely, you can do this from the info menu. Select File->Info->Reduce File Size then check the box for Remove Unused Master Shapes and it works.

Paul Herber

Sorry, I didn't mean to be rude, but the problem is just naming of the masters in the Document Master stencil.
The solution is just to delete the unwanted shape(s) from your document, then open the Document Stencil (Shapes -> More Shapes -> Show Document Stencil) and delete the appropriate master. You can also do the latter task by menu File -> Reduce File Size and selecting Remove unused master shapes.
Now you can add your modified shape to the page and it should show the correct name.
The problem arises from the master shape's Name and NameU (and MasterName and MasterNameU), the shape's local and universal names.
Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/