search for form fields within a document

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to find a form field and replace with other data. For example
....Select Leadership Competency... is a form field. If this form field has
not been selected, ...Select Leadership Competency... remains shown on the
form. I would like to find this form field and replace it with "No
Selection". I haven't been able to use the search/find/replace feature
because this doesn't recognize ...Select Leadership Competency... at all
since it is a form field. Any suggestions?
 
Miskacee said:
I'm trying to find a form field and replace with other data. For
example ...Select Leadership Competency... is a form field. If this
form field has not been selected, ...Select Leadership Competency...
remains shown on the form. I would like to find this form field and
replace it with "No Selection". I haven't been able to use the
search/find/replace feature because this doesn't recognize ...Select
Leadership Competency... at all since it is a form field. Any
suggestions?

You'll need a macro to go through all the form fields, looking for ones that
have the default value and changing them to "No Selection".

Are these all dropdown fields? Is the displayed default text always the
first item in the dropdown's list? If both of those assumptions are true,
this macro will do:

Sub SetNoSelection()
Dim oFF As FormField

For Each oFF In ActiveDocument.FormFields
With oFF
If .Type = wdFieldFormDropDown Then
If .DropDown.Value = 1 Then
.Range.Text = "No Selection"
End If
End If
End With
Next oFF
End Sub

See http://www.gmayor.com/installing_macro.htm if necessary.

This replaces the entire form field with the plain text phrase; it won't be
a field any more. If you want to retain the field, then "No Selection" will
need to be an item in each dropdown's list -- for example, if it's always
the second item in the list, you could just replace the line

.Range.Text = "No Selection"

with

.DropDown.Value = 2

The macro could be assigned to a toolbar button or shortcut key, or it could
be used in a macro that captures the Save or Print event
(http://word.mvps.org/FAQs/MacrosVBA/InterceptSavePrint.htm).
 

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

Back
Top