EDIT FORM FIELD OPTION

W

William

I have a document with a drop down form field. One of the options has a typo
I'd like to change, but I can't seem to do it in the Drop Down Form Field
Options dialog box. The item is one of those very long webpage addresses so
I'd like to find an easy way to change one character in the address.

Can this be done?
 
G

Graham Mayor

You will have to delete the incorrect item from the form field properties
(with the form unlocked) and then add it back again.

or

You could use the following macros. Make a note of the dropdown form field
name. The first should be run with the form containing the field to be
edited opened as the active document. A second document is created
containing the entries from the dropdown field. Edit that document to
correct the typo. Then with that document on screen as the active document,
run the second macro. (It will work with Word 2007 docx also and can be run
while the document is protected for forms).

Sub Macro1()
Dim oField As FormField
Dim oDoc As Document
Dim oDatadoc As Document
Dim sName As String
sName = InputBox("Enter dropdown field name")
Set oDoc = ActiveDocument
Set oDatadoc = Documents.Add
Set oField = oDoc.FormFields(sName)
For i = 1 To oField.DropDown.ListEntries.Count
oDatadoc.Range.InsertAfter oField.DropDown.ListEntries(i).name & vbCr
Next i
oDatadoc.Variables("varFormName").Value = oDoc.FullName
oDatadoc.Variables("varFieldName").Value = sName
End Sub

Sub Macro2()
Dim oField As FormField
Dim oDoc As Document
Dim oDatadoc As Document
Dim sFName As String
Dim sName As String
Dim oRng As Range
Set oDatadoc = ActiveDocument
sFName = oDatadoc.Variables("varFormName").Value
sName = oDatadoc.Variables("varFieldName").Value
Set oDoc = Documents.Open(sFName)
Set oField = oDoc.FormFields(sName)
oField.DropDown.ListEntries.Clear
For i = 1 To oDatadoc.Paragraphs.Count - 1
Set oRng = oDatadoc.Paragraphs(i).Range
oRng.End = oRng.End - 1
oField.DropDown.ListEntries.Add oRng, i
Next i
End Sub


http://www.gmayor.com/installing_macro.htm


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

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
J

Jay Freedman

William said:
I have a document with a drop down form field. One of the options
has a typo I'd like to change, but I can't seem to do it in the Drop
Down Form Field Options dialog box. The item is one of those very
long webpage addresses so I'd like to find an easy way to change one
character in the address.

Can this be done?

It can be done, but not very easily. The only method of correcting dropdown
entries is to delete the existing one and then insert the edited one. The
difficult part is getting a copy of the existing entry so you can edit it.
Here are the steps:

- Uprotect the form.
- Double-click the dropdown field to open its Properties dialog, and copy
the content of the Bookmark box. In the dropdown list, click once on the
entry to be edited. Close the Properties dialog.
- Somewhere else in the form, press Ctrl+F9 to insert a pair of field
braces. Paste the bookmark name between the braces, and press F9 to update
the field. It should show the entry to be edited.
- Click on the field you just updated, and press Ctrl+Shift+F9 to unlink the
field -- that turns it into plain text.
- Make the editing change you need, and cut the resulting text to the
clipboard.
- Reopen the Properties dialog. Remove the incorrect entry, paste the
correct entry into the Add box, and use the up/down arrows to adjust the
order if necessary.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
J

Jay Freedman

Please ignore all this blather. There is a much simpler solution.

- Open the dropdown's Properties dialog.
- Select the incorrect entry.
- Click the Remove button. The entry that has been removed from the list now
appears in the box to the left.
- Change the character as needed.
- Click the Add button. Adjust the order of entries if necessary.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 

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