If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Layers problems: Same ID
I am working on a Visio drawing with many lines. The lines are colour-
coded, into about 6 different colours. I created layers for each colour, and my goal was to create a set of macros where I could selectively show different types of lines. I have a small legend in the corner with a sample line for each colour, and by double clicking on a given line you can toggle visibility for that type. It is very simple. What I did was record a macro for an example (pink). The macro consisted simply of me going to 'Layer Properties' and unchecking the box that says 'visible' for pink. Then I did the same thing except checked it back. I edited the code by throwing in an if-statement and the macro was done. The issue I am having is that after doing that for each colour, I experienced weird problems. For example, this is the code for the black line macro (after I edited it with the if statement and cleaned it up a bit): Sub BlackLines() Dim vsoLayer1 As Visio.Layer Dim UndoScopeID2 As Long UndoScopeID2 = Application.BeginUndoScope("Layer Properties") Set vsoLayer1 = Application.ActiveWindow.Page.Layers.Item(4) ' checks which switch to execute If vsoLayer1.CellsC(visLayerVisible).FormulaU = "1" Then vsoLayer1.CellsC(visLayerVisible).FormulaU = "0" Else vsoLayer1.CellsC(visLayerVisible).FormulaU = "1" End If Application.EndUndoScope UndoScopeID1, True End Sub ----- All the macros are similar (they just have different Item IDs), but some of the macros are identical! My PinkLines macro also uses the Item (4) identification. I know this is not a typo or anything because to check to make sure I wasn't crazy, I recorded a macro that turned off visibility for black lines. Without even looking at the code, I manually turned the visibility for black lines back on, and ran the macro. It took out the pink lines. Has anyone experienced something like this before? Any help or ideas would be great. Thanks |
#2
|
|||
|
|||
Layers problems: Same ID
On Wed, 14 Jan 2009 06:26:08 -0800 (PST), Sachin
wrote: I am working on a Visio drawing with many lines. The lines are colour- coded, into about 6 different colours. I created layers for each colour, and my goal was to create a set of macros where I could selectively show different types of lines. I have a small legend in the corner with a sample line for each colour, and by double clicking on a given line you can toggle visibility for that type. It is very simple. click in the page itself to ensure no shape is selected, the menu Window - Show Shapesheet and look at the Layers section. Are the layers in the order you expect them? You should access the layers by name rather than by index. Set vsoLayer1 = Application.ActiveWindow.Page.Layers.Item("pink") etc. -- Regards, Paul Herber, Sandrila Ltd. Electrical for Visio http://www.electrical.sandrila.co.uk/ |
#3
|
|||
|
|||
Layers problems: Same ID
Thank you. Accessing by name instead of index is the key.
|
Thread Tools | |
Display Modes | |
|
|