View Single Post
 
Old 11-21-2018, 05:20 AM
gmaxey gmaxey is offline Windows 7 32bit Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,428
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Sorry I was out all day yesterday and couldn't get back to you. May I suggest:


Code:
Sub ClearForm()
Dim oCC As ContentControl
Dim lngProtType As Long
  lngProtType = -1
  If ActiveDocument.ProtectionType <> wdNoProtection Then
    lngProtType = ActiveDocument.ProtectionType
    ActiveDocument.Unprotect
  End If
  For Each oCC In ActiveDocument.ContentControls
    On Error Resume Next
    oCC.Range.Editors.Item(1).Delete
    On Error GoTo 0
    If oCC.Type = wdContentControlRichText Then oCC.Type = wdContentControlText
    If oCC.Type = wdContentControlDropdownList Then
      oCC.Type = wdContentControlText
      oCC.Range.Text = ""
      oCC.Type = wdContentControlDropdownList
    Else
      oCC.Range.Text = ""
    End If
    oCC.Range.Editors.Add (wdEditorEveryone)
  Next oCC
  ActiveDocument.Protect lngProtType
End Sub

Couple of things:
1) You don't need to select the content control to clear it.
2) If you are not using legacy "formfields" in your form then there is no reason to use that type of protection.
3) If you don't need to let the user's format the text then you don't need the rich text fields. With plain text fields, you can tab between the fields.
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote