View Single Post
 
Old 11-20-2018, 10:37 PM
Rafi Rafi is offline Windows 7 64bit Office 2016
Novice
 
Join Date: Nov 2018
Location: Israel
Posts: 14
Rafi is on a distinguished road
Default

Quote:
Originally Posted by Guessed View Post
Are you using a password on the form protection? Assuming there is no password, and the form is protected before the macro is run, the following modifications would be required.
Code:
Sub ClearForm()
  Dim aCC As ContentControl
  ActiveDocument.Unprotect
  For Each aCC In ActiveDocument.ContentControls
    aCC.Range.Select
    If aCC.Type <> wdContentControlDropdownList Then
      aCC.Range.Text = ""
    Else
      aCC.Type = wdContentControlText
      aCC.Range.Text = ""
      aCC.Type = wdContentControlDropdownList
    End If
  Next aCC
  ActiveDocument.Protect wdAllowOnlyFormFields
End Sub
This code will fail if the form is not already protected or has a password so a better solution would be to add more lines of code to check first.
there is no password .
I may have been wrong somewhere.
I've done a process of:
Fill out details,
Activating the macro to clear the details,
(happy)
Protect form (no password).

I will try again.
Reply With Quote