Hello I am novice to VBA so please excuse me if the question is too simple.
I am writing set of codes on a Visio file that has multiple pages and each pages has many layer but one common layer called "P&ID". One of the code i am writing is to loop through each page starting from page 2 and loop through each layers and if there are no visible layers then hide the page. But when looping through layers i dont want to check the condition for visibility on "P&ID" layer (because this layer will always be on). I wrote this code but did not work and i know i made this complicated.
Public Sub ShowHidepage()
Dim flg As Boolean
Dim pag As Integer
Dim j As Integer
Dim c As Integer
Set flg=false
pag = ActiveDocument.Pages.Count
For j = 2 To pag
c = 1
Do While ActiveDocument.Pages(j).Layers(c) <> "P&ID"
If ActiveDocument.Pages(j).Layers(c).CellsC(visLayerVisible).FormulaU = "1" Then
flg = True
Exit Do
Else
flg = False
End If
c = c + 1
Loop
If flg = True Then
ActiveDocument.Pages(j).PageSheet.CellsSRC(visSectionObject, visRowPage, visPageUIVisibility).FormulaU = "1"
Else
ActiveDocument.Pages(j).PageSheet.CellsSRC(visSectionObject, visRowPage, visPageUIVisibility).FormulaU = "0"
End If
Next j
End Sub