is there a way, via vba, to remove all protection on all shapes on a drawing?
Thanks
The answer has to be yes and no.
Yes, it is possible, with VBA to iterate through all pages, all shapes on those pages (and recurse through grouped shapes) removing all the protection attributes.
However ...
- if shapes have protection it is usually for some purpose
- removing the protection might break the shape
- some aspects of a shape can be protected in ways that cannot easily be removed without a deep understanding of cell formulas, i.e. guarded values/formula.
Gotta love those "yes & no" answers!
I guess I dont need to remove ALL protection...
my problem is I need to modify a bunch of old drawings, meaning mostly a lot of cut&paste and moving things about. Its getting REALLY annoying to paste a group of objects into a new drawing, move the highlighted objects into place and find a bunch of lines going out into space because someone put protection on and end point or something like that. Then I have to do and "undo" to put the objects back where they were, pick out the lines that had some type of movement protection, unprotect them then move them all where I want them. Its taking way to much time to do a simple task. >:(
Thats why I was hoping I could find a bit of code here that would at least get me a start on a macro to remove some of the protections on every object in a drawing.
Ok, in that case you don't really need VBA at all.
Select all shapes (Control-A), menu Format -> Protection -> None -> OK.
Repeat for each page.
That was the first thing I tried, it dont work.
I select all on the page, go to menu->format, all the boxes are clear.
I move my selection (or mirror, etc), lines are all wacked out.
I select the wacked line, menu->format and its got protection on x, or y, etc.
The selection may not have protection, but individual items may...
Do you mean that it has a guarded formula?
I dont even know what a "guarded" formula is, and I dont think there is anyone at my work who is visio enough to do that.
When I select the individual entities, I can remove the protection from them as stated above.
Hmm, I wonder if we have shapes on locked layers, or a protected document?
Bring up the Document Explorer window, right-click on the drawing node and choose Protect Document. Uncheck any items that happen to be checked.
Any possiblity that you could provide a Visio file example?
Sorry I took so long, been doing other chores ::)
The objects are not on locked layers, neither is the document protected.
I will look for something I can send in, will take a while, proprietary stuff.
thanks
Ok, here's a small sample. (sorry I took so long, been busy!)
If you select everything on the page, then right click and go to protection, it says that the selection is unprotected. If you then move the selection (say out of the page so you can see it more clearly), some of the items move and others dont. If you then select the items that did not move, you find that they have some x or y protection on them. There are no layers in the drawing, and the drawing itself is not protected.
Thats why I'm looking for an "unprotect all" macro, to get rid of these kinds of headaches!
The problem is with selecting all shapes. Visio decides which is the 1st shape selected and then adds the other shapes to the selection group. If the 1st chosen has no protection issues, then, it would appear that none of the selections have any problems. Obviously, that isn't necessarily true.
One work around would be to 1st apply all protections to the selection, and then apply no protections. This will remove any and all protections from the selected group. You are now free to move about the drawing.
Wapperdude
A good tip Wapper
thanks for the info ;D
I need to do the same thing - remove shape protection from a 2010 monthly calendar so I can turn it into a 2011 monthly calendar. Sadly there isn't a 2011 Visio monthly calendar format on microsoft online yet. I tried ctrl+A, Format...protection...turn on for all, turn it off. But still when I try to edit the text box, error msg says "shape protection and/or layer properties prevent complete execution of this command." I don't want to have to edit the protection for every cell, 365 for the whole year. There must be a way to remove this for the entire calendar. ideas? thanks.
never mind. I thought, why go to all this trouble! I'll just create new 2011 calendars in Visio using the calendar shape.
Regarding calendars -- VisioGuy did this nice variation for 2010. It might be easily adaptable for 2011, I haven't tried yet.
http://www.visguy.com/2009/12/29/visio-2010-calendar-template/
HTH
Enjoy!
Wapperdude
Good tip and thanks for the explanation as well!Your answer is still helping others after all this time.
Quote from: wapperdude on December 16, 2010, 08:13:50 PM
The problem is with selecting all shapes. Visio decides which is the 1st shape selected and then adds the other shapes to the selection group. If the 1st chosen has no protection issues, then, it would appear that none of the selections have any problems. Obviously, that isn't necessarily true.
One work around would be to 1st apply all protections to the selection, and then apply no protections. This will remove any and all protections from the selected group. You are now free to move about the drawing.
Wapperdude
BTW....same problem with groups and subshapes
select "remove all protections" for group leaves subshapes as they were originally
After stumbling with this same issue, a work-around I found was to 1) select the set of shapes, 2) group the objects, 3) then delete the group.
Quote from: wapperdude on December 16, 2010, 08:13:50 PM
The problem is with selecting all shapes. Visio decides which is the 1st shape selected and then adds the other shapes to the selection group. If the 1st chosen has no protection issues, then, it would appear that none of the selections have any problems. Obviously, that isn't necessarily true.
One work around would be to 1st apply all protections to the selection, and then apply no protections. This will remove any and all protections from the selected group. You are now free to move about the drawing.
Wapperdude
Wapperdude,
You are a genius and a life-saver. I have a fairly complex drawing I created myself. My fat fingers kept moving objects I didn't mean to, causing a lot of extra work, some of which I didn't notice until later. I got the bright idea to lock each shape once I got it the way I wanted it. This actually worked fairly well until I wanted to move the whole drawing over a bit to make room some something else. I tried select all shapes and setting all protections off. It didn't work as the OP discovered. So I was left to select each shape individually, a very tedious process.
Finally, I got fed up and searched for a cure. Google, bless it's black corporate heart, found this thread. Your solution worked perfectly.
Thank you, thank you, thank you.
PS: Judging by the number of views of this thread (93,120), you have saved a lot of people a lot of trouble. That's almost 54 views/day since the original post (11/30/10) -- 1,727 days. Amazing.
PPS: And I am appalled at the stupidity of the Microsoft developers. I know I shouldn't be after all these years suffering through the countless bugs and glitches in Word, Excel, Outlook, VBA, etc. What moron thought this was a good implementation?
Thanks, Jennifer. Funny, never really thought about long term implications, nor considered that this might be a wide spread problem. Whoda thought! ???
Quote from: wapperdude on August 24, 2015, 12:01:48 AM
Thanks, Jennifer. Funny, never really thought about long term implications, nor considered that this might be a wide spread problem. Whoda thought! ???
Well, you saved me at least an hour of locking and unlocking shapes one at a time -- not to mention the toll on my nervous system from all the cursing and the broken glassware hurled against the wall. At one point, I was considering throwing the computer out the window. >:(
;D
Another option I tried in my Microsoft Visio Standard 2013 was: File > Options > Advanced (General Section) > Check "Run in Developer Mode". When you'll get a "DEVELOPER" tab on the Visio main window, select the shape that you want to delete, then inside the "DEVELOPER" tab, there is an "operations" drop down. Click the "fragment" option. Then try to delete the shape. It worked for me. I had tried to uncheck Protect "From deletion" when you're in the "Protection" option inside the "DEVELOPER" tab, and also tried to check/uncheck to try and trick the option, but no luck with that.
You can recursively unprotect all the shapes in group:
Sub UnprotectSelection()
Dim i As Long
For i = 1 To Application.ActiveWindow.Selection.Count
RecursiveUnprotection Application.ActiveWindow.Selection(i)
Next
End Sub
Sub RecursiveUnprotection(grp As Shape)
Dim i As Integer
For i = 0 To 19 ' grp.Section(visSectionObject).Row(visRowLock).count
grp.Section(visSectionObject).Row(visRowLock).Cell(i).Formula = 0
Next i
If grp.Type = visTypeGroup Then
Dim shp As Shape
For Each shp In grp.Shapes
RecursiveUnprotection shp
Next shp
End If
End Sub