Sheet.ID Bug?

Started by david, May 12, 2009, 12:14:00 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

david

i encountered recently a bug that really drives me crazy.

i sometimes drag a shape called "Polygon" (that's the master name) from the stencil to the frame but as soon as i drop it, its name changes to "Sheet.17".  i debugged it and i saw that at the first command of ShapeAdded event, the name has already been changed to Sheet.17.  therefore i think its visio's bug and not mine (maybe not...).  also, it happens once in a while and i can't predict it.  i never know if the name is gonna be sheet.17 or Polygon.(some number).

this bug is making me serious problems at the code since i recognize groups by their name (if the name starts with "Sheet" then it's a group otherwise it's not).  since some of the masters are also groups, this was the only way i knew to recognize them.  now because of the bug, visio thinks that the Polygon is a group and i don't know how to fix it...

anyone can help me with this?
there must be another way to recognize a group.

Paul Herber

#1
Would you like to post a copy of the shape here?

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

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

david

#2
hi Paul,

i really don't know what to post here.  i can't post only the shape. i should post the whole program so you can see the problem i talked about.  but the program is much more than 500 kB.

did you encounter the situation? or do you know how to deal with it?

Paul Herber

#3
Just the shape will do, create a new blank stencil, add the shape to the stencil, save the stencil and post the .vss file here.

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

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

wapperdude

David --

So, it's just this one shape that does it?  I tried a variety of shapes, from a variety of stencils and could not reproduce any "misnaming" events.

Have you tried opening a new document, and then just repeatedly placing that shape?  Does the error still occur?  What about a new page in the document with the problem?

WApperdude
Visio 2019 Pro

david

Hi Paul and Wapperdude,
you're right. when i moved the polygon to a new stencil and opened a new visio file, there was no such a problem.  therefore i don't see a point sending the polygon shape here.  btw, it's not only the polygon. it sometimes a rectangle also and probably other shapes as well.

so maybe it's really my bug in the program and not visio's.  but still, i put a breakpoint at the first command of shapeadded event.  and the name has already been changed to "Sheet.17".  what could possibly happen before that???  i don't even know how to change the shape's name through its shapesheet so i really don't understand how it could happen...

any idea?

and at the same issue.  how can i recognize that a shape is a group except for checking if its name starts with "Sheet" (considering the masters are also groups so i can't use shape.shapes.count)?

wapperdude

Well, to the first issue... you're adding the shape programmatically?  So, on a page where the problem exists, can you try adding the shapes manually?  If that goes OK, then it's probably a code issue.  If that fails, then it might be that page became corrupt somehow.  I think you have to run the experiment on one or two new files to see if it reproduces.

Second issue... seems like this has come up before.  You might search the site for group or subgroups or whatever and see what comes up.
Visio 2019 Pro

david

i'm not adding the shape programmatically. i'm adding it manually.  however, i did write a lot of code in shapeadded and many more events and functions.  so who knows maybe something happened there somewhere.

i have only one vsd file.  the file with the code.  so what do you mean trying it in another file? a new file without the code i wrote? it works there without bugs but i need my code...

what do you mean the page became corrupt? what should i do about that?

i'm trying to understand where anything could go wrong since nothing happends before the first command of shapeadded.

aledlund

#8
doing my usual muddying the water. I think the question started with
"there must be another way to recognize a group."

why not:

    Dim visWin As Visio.Window
    Dim visShape As Visio.Shape
    Set visWin = Application.ActiveWindow
    If visWin.Selection.Count = 1 Then
        Set visShape = visWin.Selection(1)
        If visShape.Type = visTypeGroup Then
            MsgBox "it is a group"
        Else
            MsgBox "it is not a group"
        End If
    End If


al

david

that's not right.

it tells me "it is a group" also for a polygon i dragged from the stencil because the polygon as a master is also a group (that's how i built it).
i don't want to consider shapes that i dragged from the stencil as groups (even if they are).  only shapes that i grouped them on the frame.

wapperdude

Hi David --

I wasn't sure of the process you were using to add shapes.  OK.  Manual it is!  

I was thinking that perhaps the file you are working in has some sort of corruption, so if you start a brand new Visio doc, that might eliminate the problem.  The other possibility would be, that only the active page in your current document has a problem, so, by opening a new page, and all is well as you add shapes and exercise code, then that would tend to point to the problem being an issue with the page and not the entire file.  The idea is to isolate the corruption to a page or a file, and then to see what (if any) code creates the problem.  So, having said that, here's a rhetorical question:  Can you start a new doc, and just use the shapeadded code rather than all of the pieces?  Basically, start from a clean slate, then add one piece at a time.  That way, you can track down the culprit.  Perhaps it was something that happened as you were working/developing your code, and is no longer an issue.

HTH
Wapperdude

Visio 2019 Pro

wapperdude

Awwww.  And it was such a nice little piece of code Al wrote!
Visio 2019 Pro

Visio Guy

#12
If you want to distinguish an "instanced master" from just any old shape that you drew (or grouped together on a page), try this:

Dim shp as Visio.Shape
Set shp = Visio.ActiveWindow.Selection(1)
If (shp.Master is Nothing) Then
  '...you've got a shape with no master
End If


I've used this type of analysis many times. There are situations when you need to walk every shape/sub-shape in a page. And you need to know if the shape is a master or not, or a data graphic or not. If a shape is from a master, I often stop digging deeper, assuming that an instanced master doesn't need to be messed with, etc.
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010

david

hi visio Guy.  thanks for the code. it was very helpful.

Wapperdude, i really don't understand what do you mean corrupted file?  i didn't know that visio's file can be corrupted. 
if that's true, then it's not good... since the file can act unexpectedly sometimes...

Paul Herber

(Repeat) Why don't you just post the shape here? It'll save so much time.
Create a new stencil and copy the shape into it.

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

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