Is there a layer limit in Visio 2003?

L

Lisa

I can't add new layers after approx. 113 without getting strange characters
in the Layer Properties window and then getting kicked out of Visio if I try
and Save. But I can copy in layers but this is only a temporary solution to
meet a deadline.

Anyone??? Thanks.

Lisa
 
J

JuneTheSecond

You are really right! I also cannot add manually new layers to more tha
about 114 or 115 layers. The names in the layer property table changes
strange, and get error message. It was the same in my another strong PC.
 
J

JuneTheSecond

But, if you add with macro, you can add more layers.
and you can change the name of layers manually.
My macro is as listed below.

' In standard Module
Option Explicit

Public Enum myProgress
minVisiProg = 30
End Enum

Sub AddLayers()
Dim i As Long, iRed As Long, iGreen As Long, iBlue As Long, Imax As Long
Dim strMax As String
Dim Lay As Layer
Dim strHead As String

strMax = InputBox("How many layers ?", , 1)
strHead = InputBox("Head of layers' name ?", , "AddedLayer")
If IsNumeric(strMax) Then
Imax = Int(strMax)
PleaseWait.Show vbModeless
If Imax > minVisiProg Then PleaseWait.ProgressBar1.Visible = True
PleaseWait.Repaint
For i = 1 To Imax
DoEvents
' If myMod(i, 5) = 0 Then GiveColor
iRed = myRnd
iGreen = myRnd
iBlue = myRnd
Set Lay = ActivePage.Layers.Add(strHead & "_" & varZero(i,
Imax) & i)
Lay.CellsC(visLayerColor).FormulaU = "RGB(" & iRed & "," &
iGreen & "," & iBlue & ")"
' Lay.CellsC(visLayerVisible).Formula = False
If Imax > minVisiProg Then
If myMod(i, 10) = 0 Then
PleaseWait.ShowProgress Imax, i
End If
End If
Next
Unload PleaseWait
MsgBox "Num of layers became " & CountLayers & "."
SendKeys "%(VL)"
End If
End Sub

Private Function myMod(i As Long, Low As Long) As Long
myMod = i - Low * Int(i / Low)
End Function

Private Function myRnd()
myRnd = Int(Rnd * 256)
End Function

Private Function varZero(i As Long, Imax As Long) As String
Dim LenNum As Long, J As Long
LenNum = Len(Str(Imax)) - Len(Str(i))
varZero = ""
If LenNum > 0 Then
For J = 0 To LenNum - 1
varZero = varZero & "0"
Next
End If
End Function

Private Function CountLayers()
CountLayers = ActivePage.Layers.Count
Debug.Print CountLayers
End Function

' UserForm named "PleaseWait" that has label and progress bar.

Option Explicit

Private Sub UserForm_Activate()
Me.Repaint
End Sub

Private Sub UserForm_Deactivate()
Unload Me
End Sub

Private Sub UserForm_Initialize()
ProgressBar1.Visible = False
ProgressBar1.Value = 0
End Sub

Private Function BarProgress(Imax As Long, i As Long) As Long
Dim TenPer As Long
If Imax > 0 Then
BarProgress = i / Imax * 100
Else
BarProgress = 0
End If
End Function

Public Sub ShowProgress(Imax As Long, i As Long)
ProgressBar1.Value = BarProgress(Imax, i)
Me.Repaint
End Sub
 
L

Lisa

Here is the other response I received from Chris Roth. I tried it this
morning and it works.

Choose: View > Immediate window and type this line in that window:

Visio.ActivePage.Layers.Add ("New Layer Name")

If you go up into the code window and add this subroutine, you can add a
bunch of layers. This sub adds layers number n+1 to n+100:

Sub AddLayers()

Dim i As Integer, j As Integer

For i = 1 To 100

j = Visio.ActivePage.Layers.Count + 1
Visio.ActivePage.Layers.Add ( "Layer " & j )

Next i

End Sub

Just copy this code into the VBA editor, then hit F5 to run it (in a test
document until you figure it all out!)

I then had to change the Macro security from High to Medium in order to
enable the macro to work.

Thank you again for your help.

Lisa
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top