keybord macro to clear fill in fields on form

C

checkQ

I created a fill in form and protected the form with a password. Users are
only allowed to enter fill in data. There are about 36 fields and users find
it laborious when they want to delete info in the fields. They have to select
each field one by one and delete contents.
I tried to assign a keyboard macro to "Clear fields" but the record macro
will not allow me to delete the field while the record macro is running. When
I try to select the form field and press delete all my field formats are
deleted as well.

Does any one know a macro that will clear the contents of more than one form
field at a time without deleting the special formats?
 
G

Graham Mayor

If you save the form as a template with the fields empty then new documents
created from it will not have content either.
As for the macro

Sub ClearForm()
Dim oFld As FormFields
Set oFld = ActiveDocument.FormFields
For i = 1 To oFld.Count
If oFld(i).Type = wdFieldFormDropDown Then
oFld(i).Result = " "
Else
oFld(i).Result = ""
End If
Next
End Sub

should do the trick

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
C

checkQ

Thanks for that macro it works perfectly when I run the macro! But I am still
faced with two problems.

1. When I protect the sheet I cannot run the macro.
2. I would like to assign the macro to a keyboard short cut ie Ctrl+K

When a sheet is protected does it somehow disable the VBA also?
 
C

checkQ

Hi Grayham,
I checked out your website and found the answer that I was looking for under
How to assign a macro to a keyboard hotkey. It worked perfectly even when I
protected the doecument to prevent changes. You are the best!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top