Hello,
I hope someone can help me please. I need to enable all protections for all shapes on 170+ pages of a Visio diagram file and I fear I will get Repetitive Strain Injury if I try this manually.
Would anyone have the VBA code to highlight/select all shapes on a page, enable all protections and then repeat for all foreground pages?
My right wrist would be eternally grateful, as would the rest of me for any help/advice.
Thx
Pin
Hi, from Russia !
Quote from: PinPinPoola on August 19, 2021, 03:48:15 PM
Would anyone have the VBA code to highlight/select all shapes on a page, enable all protections and then repeat for all foreground pages?
I haven't this code before, just write this code in few minutes
Sub PinPinPoola()
Dim pg As Page
Dim shp As Shape
Dim PS As Section
Dim pr As Row
Dim pc As Cell
For Each pg In ActiveDocument.Pages
For Each shp In pg.Shapes
Set PS = shp.Section(visSectionObject)
Set pr = PS.Row(visRowLock)
For r = 0 To pr.Count - 1
Set pc = pr.Cell(r)
pc.FormulaU = "0"
Next
Debug.Print shp.Name & " disabled"
Next
Debug.Print "all shapes at page" & pg.Name & " are disabled"
Next
End Sub
Hello @Surrogate
Thank you for your help.
I have just tested this and it works for basic line drawn shapes, but when I use a server shape from HPE, it fails with a "Run-time error '-2032466648 (86db0528)': Cell is guarded."
Any ideas?
Thx
Pin
Quote from: PinPinPoola on August 19, 2021, 08:22:43 PM
"Run-time error '-2032466648 (86db0528)': Cell is guarded."
Any ideas?
Try change row
pc.FormulaU = "0" to
pc.FormulaForce = "0"
Hello @Surrogate
That worked - Thank you so much!!!
Have a great weekend.
Pin
You also use put the equal sign before the zero.
pc.FormulaU = "=0"