A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Powerpoint, Publisher and Visio » Visio
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Layers problems: Same ID



 
 
Thread Tools Display Modes
  #1  
Old January 14th, 2009, 02:26 PM posted to microsoft.public.visio.general
Sachin[_2_]
external usenet poster
 
Posts: 15
Default 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  
Old January 14th, 2009, 03:58 PM posted to microsoft.public.visio.general
Paul Herber
external usenet poster
 
Posts: 1,732
Default 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  
Old January 14th, 2009, 04:34 PM posted to microsoft.public.visio.general
Sachin[_2_]
external usenet poster
 
Posts: 15
Default Layers problems: Same ID

Thank you. Accessing by name instead of index is the key.
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 02:11 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.