PDA

View Full Version : Visio 07 - sometimes shapes/layers won't hide



rokuk
11-11-2008, 10:14 AM
Hi there.

I have a visio 2007 application I inherited, the previous people had used most the macro recorder to meet their custom VBA needs. I am trying to understand the auto-code here, but am having trouble debugging something. This related to hiding certain shapes in a specific layer that will not go away.

On the sheet, there is a "Show Menu" button. If it is double-clicked it runs a function to pop up several new menu buttons (when those menu buttons are clicked, they run other custom functions). This all works fine.

When the "Show Menu" button is clicked a second time, it is supposed to hide the menu buttons that have popped up. This partially works - it will hide any of those menu buttons that were NOT used, but any of them that were used will continue to stay visible - and I can not figure out why!!


This is how the VBA code is currently written for toggling the menu buttons on and off (in the "Show Menu" button function). I understand the general gist of how it works, but I must be missing something.




Set vsoLayer1 = Application.ActiveWindow.Page.Layers.Item("myMenuButtons")

If vsoLayer1.CellsC(visLayerVisible).FormulaU = "0"
Then vsoLayer1.CellsC(visLayerVisible).FormulaU = "1"
Endif

If vsoLayer1.CellsC(visLayerVisible).FormulaU = "1"
Then vsoLayer1.CellsC(visLayerVisible).FormulaU = "0"
Endif


The only thing I can think of is that when the menu buttons are clicked they are being taken out of their layer, or locked from being modified or something somehow. I know there is code for each menu button as well that is not posted here, but it didn't seem like it would affect their visibility... I mean they should still be part of the layer, right? I can try to post that too if anyone thinks it would be helpful...

Any thoughts?

Thank you!!

Tommy
11-11-2008, 11:31 AM
Hi rokuk,
not knowing anything about visio 2007 try this


Set vsoLayer1 = Application.ActiveWindow.Page.Layers.Item("myMenuButtons")
If vsoLayer1.CellsC(visLayerVisible).FormulaU = "0" Then
vsoLayer1.CellsC(visLayerVisible).FormulaU = "1"
ElseIf vsoLayer1.CellsC(visLayerVisible).FormulaU = "1" Then
vsoLayer1.CellsC(visLayerVisible).FormulaU = "0"
End If

rokuk
11-11-2008, 12:25 PM
Thank you kindly for your response = )

This results in the same behaviour, unfortunately...

I notice one thing: when I put in a:

MsgBox(visLayerName)

it returns a "0" ... I thought I should get it to return "myMenuButtons" instead... am I mistaken? does this mean anything?

Tommy
11-11-2008, 02:10 PM
This should show you the "myMenuButtons"
Msgbox(vsoLayer1.Name)

I have no idea what visLayerName is. It is not defined so far as what has been posted. Also I would think that the visible property would be vsoLayer1.Visible not vsoLayer1.CellsC(visLayerVisible).FormulaU

But as already stated I do not know visio and have no access to test it with, I have to depend on you to help me help you unless someone else that knows visio will post.

What is CellsC? Is that supposed to be Cells?