brothertruffle880
asked on
Visio VBA - Switching Layers with a macro
I have a macro that switches from a :
technical layer (with IP addresses and port numbers).
management layer (no IP addresses, just icons and host names
CTRL + T for technical
CTRL + M for managerial
Works fine on one sheet.
On page 2, I just created a technical layer, assigned objects and for some reason, the OPPOSITE is taking place. CTRL + T is showing me the managerial view. CTRL + M is showing me the tecnical view.
Same layer names, different page. Macro works the opposite way! "T" is now showing managerial view "M" is now showing technical view.
How can I fix this?
technical layer (with IP addresses and port numbers).
management layer (no IP addresses, just icons and host names
CTRL + T for technical
CTRL + M for managerial
Works fine on one sheet.
On page 2, I just created a technical layer, assigned objects and for some reason, the OPPOSITE is taking place. CTRL + T is showing me the managerial view. CTRL + M is showing me the tecnical view.
Same layer names, different page. Macro works the opposite way! "T" is now showing managerial view "M" is now showing technical view.
How can I fix this?
ASKER
Hi Visio Guy:
YES!
You nailed it. You precisely stated exactly what I did.
Actually, I created three layers in a different order on some pages.
Can you help me fix it. I'm not a VBA guru so I'm not sure what your code above does.
I have about 30 pages. There are actually three layers: management, technical and logistics. I would like to set up macros so that a user presses CTRL + T to see the technical layer, CTRL + M to see the management layer and CTRL + L to see the logistics layer.
YES!
You nailed it. You precisely stated exactly what I did.
Actually, I created three layers in a different order on some pages.
Can you help me fix it. I'm not a VBA guru so I'm not sure what your code above does.
I have about 30 pages. There are actually three layers: management, technical and logistics. I would like to set up macros so that a user presses CTRL + T to see the technical layer, CTRL + M to see the management layer and CTRL + L to see the logistics layer.
Hi BT,
Do you need to assign shapes to layers, or is that already done?
Ie: do you simply need to flip the visibility of the layers on each page according to the names/keyboard shortcuts?
Do you need to assign shapes to layers, or is that already done?
Ie: do you simply need to flip the visibility of the layers on each page according to the names/keyboard shortcuts?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
You are amazing! Thanks!
The layers on the new page might have been created in a different order than on the first page (look at the ShapeSheet for each page). I suspect you used a macro-recording from the first page, which needs a bit of parametrization.
It's best to find a layer by name, rather than depend on some sort of index. Here's some test code that uses a GetLayerByName function to get a Visio layer object:
Open in new window