View Single Post
 
Old 11-20-2018, 10:22 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

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.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote