Word document protection

I know how to protect a document but I want to have some options for the person viewing it.

What I am creating is a form. It contains questions with select-able options for answers and comment boxes. I can currently lock the form so they can only fill out the form BUT I also want them to be able to highlight the questions and remarks and copy them to their clipboard to be reattached in their own document if desired. 

I just don't want the questions to be changed. only answered and copied to a clipboard WITHOUT the password to unlock the form.

Thank you for your help

Josh

This is possible with a macro, but not otherwise. The macro below will unprotect the form just long enough to copy the text, and then restore the protection.

  • Create the form as a macro-enabled document or template.
  • Open the macro editor (Alt+F11).
  • Select the name of the form/document in the Project pane. Click Insert > Module.
  • Click Tools > References. In the list of available items, locate "Microsoft Forms 2.0 Object Library" and check the box next to it. Click OK.
  • Paste in the code from the bottom of this post.
  • Change the value of the constant named pwd to the password you use for protecting the form.
  • Click Tools > Project Properties, go to the Protection tab of the dialog, check the box to lock the project, and enter a password that will be needed in order to view or edit the macro. That prevents unauthorized people from seeing the form password in the code.
  • Somewhere in the body of the form, insert a field (using Ctrl+F9 to insert the brackets) with the field code  {MACROBUTTON CopyForm Click here to copy the form} .
                                

Sub CopyForm()
    Dim MyData As DataObject
    Const pwd As String = "foo"

    On Error GoTo ErrHdl
    With ActiveDocument
        If .ProtectionType <> wdNoProtection Then
            .Unprotect Password:=pwd
        End If

        Set MyData = New DataObject
        MyData.SetText Text:=.Range.Text
        MyData.PutInClipboard

        .Protect Type:=wdAllowOnlyFormFields, _

            NoReset:=True, Password:=pwd
    End With

    Exit Sub

ErrHdl:
    If .ProtectionType <> wdNoProtection Then
        .Protect Type:=wdAllowOnlyFormFields, _

            NoReset:=True, Password:=pwd
    End If

    MsgBox Err.Number & vbCr & Err.Description, , "Error"
End Sub

Sub AutoOpen()
    Options.ButtonFieldClicks = 1
End Sub
Sub AutoNew()  ' remove this sub if the form is NOT a template
    Options.ButtonFieldClicks = 1
End Sub

_____________________________
https://jay-freedman.info

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated April 14, 2025 Views 222 Applies to: