Quote:
Originally Posted by gmaxey
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.
|
First of all, I'm sorry for the late reply.
The code works
very smoothly.
The day before yesterday, for an entire day, I tried to apply the code on this form and onto other short forms, and I encountered several problems.
Yesterday I decided to follow your advice, and replaced
all the boxes with rich text, into a simple text boxes.
It made everything work Smooth.
In A4 forms with lots of scroll down boxes (about 100), resetting takes a lot of time, (about 30 sec) but in the end it is done correctly.
what do mean by saying : "
If you are not using legacy "formfields" in your form then there is no reason to use that type of protection." ?
How else could I build the form without users having the ability to change it?
Thank you all for your responsiveness and professional help!