Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #14  
Old 11-27-2018, 12:16 AM
Rafi Rafi is offline Reset "Button" to clear Word user-filled form, from all filled details. Windows 7 64bit Reset "Button" to clear Word user-filled form, from all filled details. Office 2016
Novice
Reset "Button" to clear Word user-filled form, from all filled details.
 
Join Date: Nov 2018
Location: Israel
Posts: 15
Rafi is on a distinguished road
Default

Quote:
Originally Posted by gmaxey View Post
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!
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
button "clear format", etc; anchors, functions and properties of OpenType, negative width of symbol? tvan Other Software 1 07-18-2018 03:55 PM
Using outlook form to enforce field to be filled in megatronixs Outlook 1 01-21-2015 01:11 PM
Text form filled shading Barbara Word 2 04-25-2013 05:21 AM
Reset &quot;Button&quot; to clear Word user-filled form, from all filled details. Add a "SAVE" Button to a form template? Dave L Word 9 03-21-2012 07:04 PM
How can create a form in Word 2007 that can be automatically filled? artistech Word 0 08-04-2010 01:05 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:06 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft