#1
|
|||
|
|||
VBA to lock everything after Save As
I have a macro assigned to a button that does a Save As and names the file in a specific location. The document is already password protected from edits with exceptions to only the text boxes that the user must fill out. Once the user is done filling out the text boxes they click the macro button and the file is saved as a .docx file. When I go to open the newly created .docx file, I would like it to be completely locked from edits. Is there a way to do this? I've tried recording macros just to see what it would take to lock all the text boxes once the user clicks the button but the only code I got was this:
Selection.Editors(wdEditorEveryone).Delete Selection.Editors(wdEditorEveryone).Delete Selection.Editors(wdEditorEveryone).Delete Selection.Editors(wdEditorEveryone).Delete Selection.Editors(wdEditorEveryone).Delete Which is quite puzzling since its not referring to any particular text box so if I were to type this code for the button, how would it know which box to not allow everyone to edit anymore? I also tried this code at the end after the Save As already triggered but it didn't see to work: ActiveDocument.Unprotect "hello" ActiveDocument.Protect Password:="hello", NoReset:=False, Type:= _ wdAllowOnlyReading, UseIRM:=False, EnforceStyleLock:=False ActiveDocument.Save I had to unprotect it first as it was already protected with the exception of the text boxes that the user could edit. Then I wanted to protect the whole document from edits and this is the code it produced when I recorded a macro to lock the document with No Changes (Read Only). Excel seems to be much more intuitive when it comes to writing VBA and using the record macro feature to help write VBA code. I feel Word leaves you more in the dark. Any help is appreciated. Thank you! |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Lock in Watermark | barrycc | Word | 2 | 05-24-2017 07:50 AM |
Any way to lock tab stops | ctenanthe | Word | 1 | 01-31-2013 11:20 PM |
When I try to save an existing word doc, save as pops up and will not save... | samanthab | Word | 3 | 01-19-2013 06:27 AM |
Num Lock ERROR | judicial85 | Excel | 6 | 05-04-2012 10:43 AM |
Lock a Slide | Pemberton | PowerPoint | 0 | 07-18-2010 04:43 AM |