I am using a VBA user form in Microsoft Word to fill in fields in a document. I have this working fine for text fields but I having more difficulty with the combo boxes.
So I have a user form called DocumentFields, with a combo called cmbColour and a button called cmdSave.
When I open this userform I fill in options in the cmbColour fields as follows:
DocumentFields.Show vbModeless
With DocumentFields.cmbColour
.AddItem "Red"
.AddItem "Green"
.AddItem "Blue"
End With
This works fine and shows the three values
When the user clicks on the save button it takes the value of the cmbColour field and saves it into a bookmark called My_Colour in the document
Dim myColour As Range
Set myColour = ActiveDocument.Bookmarks("My_Colour").Range
myColour.Text = Me.cmbColour.Value
ActiveDocument.Bookmarks.Add "My_Colour", myColour
This also works fine
The problem is when I close the user form and then open it up again I want it to read the value that is in the bookmark, and select the correct field in cmbColour so it remembers which one was last selected.
i.e. If they previously had selected red, it would read in the value "red" from the bookmark field, loop through the cmbColours items and select the one that matched or none if there was no match.
I have tried lots of different code samples for this but none of them seem to work.
I think most of them seem to be written for excel but I don't seem to be able to get them to work in word.
Does anyone know how I can do this in Word? Any help would be most appreciated!