Let's be clear about formfields verus bookmarks.
All formfields are bookmarks, but not all bookmarks are formfields.
Are you trying to use the ComboBox result, and put that result into REAL
bookmarks, or formfields?
If they are bookmarks, NOT formfields, you could do it like this.
Sub FillABookmark(strBM As String, strText As String)
Dim oRange As Word.Range
Set oRange = ActiveDocument.Bookmarks(strBM).Range
ActiveDocument.Bookmarks(strBM).Range.Text = strText
With oRange
.Collapse Direction:=wdCollapseEnd
.MoveEnd Unit:=wdCharacter, Count:=Len(strText)
End With
ActiveDocument.Bookmarks.Add strBM, Range:=oRange
End Sub
Private Sub ComboBox1_Change()
Dim var
Dim oBM As Bookmark
Dim BM_Names()
‘ set the array of bookmark names
BM_Names = Array("Northline Piston FSGR450", _
"Northline Piston FSGR460", "Akron Ball 7825", _
"Akron Ball 8825", "Akron Butterfly 7950", _
"Akron Butterfly 7960", "Hale Butterfly 538-1560-20-0", _
"Triton Butterfly Valve", "Hasbra Butterfly 270-6", _
"Hasbra Butterfly 270-5")
‘ loop through every bookmark and make the range
‘ the text from ComboBox1
For Each oBM In ActiveDocument.Bookmarks
For var = 0 To Ubound(BM_Names)
Call FillABookmark (BM_Names(var), ComboBox1.Value)
Next
Unload Me
End Sub
That would put the ComboBox1 text value into every bookmark.
This is NOT the same as putting the value into every formfield.
Private Sub ComboBox1_Change()
Dim oFF As Formfield
‘ loop through every formfield and make the Result
‘ the text from ComboBox1
For Each oFF In ActiveDocument.Formfields
oFF.Result = ComboBox1.Value
Next
Unload Me
End Sub
This would make every formfield equal ComboBox1.Value. This is assuming that
every formfield is a text formfield. If some are not, then you must test to
see if it is a text formfield.
Can you explain more clearly? Are the things you are trying to put text into
formfieds – inserted from the Forms toolbar? Are they real bookmarks –
inserted through Insert > Bookmark?
Thanks Doug Robbins
The article that you offered me is the one that I have been using to learn
on how to create a ComboBox macro. But as you can see the first line states
the bookmark name. how can I add more bookmarks without having to create a
whole new macro for each bookmark.
My programing level is beginer, working in Words 2002
I would suggest that instead of using a DropDown formfield at each location,
you use a Text Formfield and have and Macro that runs on entry to the
[quoted text clipped - 8 lines]
bookmark
how can I use the same drop down list for each different bookmark