rotcheck.blogg.se

How to lock word document from editing 2016
How to lock word document from editing 2016




how to lock word document from editing 2016
  1. #How to lock word document from editing 2016 full#
  2. #How to lock word document from editing 2016 code#
  3. #How to lock word document from editing 2016 password#

Since you're not setting any editable areas in the document, for either protection type, it wouldn't make any difference that I can see which you use. If you were to implement protecting for forms instead of "read-only" you could avoid this. So you need to protect again after saving, then do a "plain" save. But when you SaveAs you're changing the document name and the document type, from not macro-capable to macro-capable.

#How to lock word document from editing 2016 full#

You're applying full read-only protection.

#How to lock word document from editing 2016 code#

I have a feeling it's either something I haven't yet learned in Word VBA or something regarding the SaveAs code is not saving the protection, any thoughts? To my understanding the whole code is in logical order and I don't see any reason it wouldn't either protect the document or when re-opened, open with protection enabled as it's been saved after protection has been set. I've stepped through the code and the line is executed. 'Some code executes here to attach the saved document to a new outlook mailitem ready for sending.Īpplication.WindowState = wdWindowStateNormal :=False, SaveAsAOCELetter:=False, CompatibilityMode:=14 WdFormatXMLDocumentMacroEnabled, LockComments:=False, password:="", _ĪddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, _ĮmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData _ If Not ActiveDocument.ProtectionType = wdAllowOnlyReading ThenĪctiveDocument.Protect wdAllowOnlyReading,, "abc123"ĪctiveDocument.SaveAs2 FileName:="H:\Assessment 1_" & yourName, FileFormat:= _ MsgBox "A new email will open with this document attached." & vbNewLine & vbNewLine & "Please click send and set the security status to 'Un-classified'", vbInformation, "For Your Information" Private Sub cmdSubmit_Click()Ĭonfirm = MsgBox("Have you checked all your answers are correct?" & vbNewLine & vbNewLine & "By clicking 'Yes' you are confirming your completion of this Assessment", vbYesNo, "Submission Confirmation")

#How to lock word document from editing 2016 password#

We'll Assume for the example that to protect/unprotect the sheet, the password is "abc123". This code is a shortened version (omitting 19 variables, 15 Bookmark references and 4 enclosing bookmark replacements). As the document is distributed with protection enabled, at first it works perfectly however after submission the saved version can be opened and edited without the UserForm if macros are not enabled (if prompted). It's preferred that the document is protected when it's opened in all instances. However the line to Protect the Document before it saves on submission does not seem to work (for lack of a better term). It protects and unprotects as intended in various blocks of code for example the override used by admins to close the userform, generally for marking and when the document opens (with macros enabled of course) or when the Userform terminates. So to overcome this I've included the code to Protect the Document from editing. The User has not 'enabled content' and have completed the document only to then 'enable content' and be forced to complete the assessment via the UserForm, thus on submission adding another answer to the bookmark locations.In short, the above works perfectly, however after testing some users managed to double up some of their answers.Īs the users are in various locations around the country, it can be difficult to get in touch (and trying to work out how things happened can be difficult with some users) so I've come to the conclusion the most logical reason would be: At the end of the form is a 'Submit' button (code shown below) which when clicked the user is prompted to confirm they are ready to submit the assessment, and if 'Yes' the form writes the values from the UserForm controls to a relevant bookmark in the document, replaces some of the bookmarks with enclosing bookmarks, saves the document, composes an email and attaches the document ready for sending, then resizes the window and closes MS Word.Navigation of the form is achieved with 'next' and 'previous' command buttons.The UserForm is 'locked' where the only way to close it is to force close MS Word OR to click a command button and enter the correct password.

how to lock word document from editing 2016

  • On open, the document 'hides' and displays a UserForm to complete the required questions, including your name (Which is shown in the below sample code).
  • how to lock word document from editing 2016

    I have a MS Word document which is a 10 question assessment made up of a table at the top containing details such as your name and table sections below, each for 1 question and answer and as required bookmarks.






    How to lock word document from editing 2016