I created a UserForm. I added a ComboBox ("cboName") with 4 names available. When the User selects a name from cboName, the value will be inserted at a bookmark titled "Name" in the Word document.
However, there are ID numbers associated with each of the names that I would like inserted in the Word document at a location different than the "Name" bookmark. Therefore, is it possible to have the ID number automatically inserted in the Word document (at a bookmark titled "ID") based on User's selection in cboName?
For example, the ID numbers associated with each name:
- Bob = 1
- Cindy = 2
- Peter = 3
- Vanessa = 4
Here is the code:
Code:
Private Sub cmdOK_Click()
Application.ScreenUpdating = False
With ActiveDocument
.Bookmarks("Name").Range.Text = cboName.Value
End With
Application.ScreenUpdating = True
Unload Me
End Sub
Private Sub UserForm_Initialize()
With cboName
.AddItem "Bob"
.AddItem "Cindy"
.AddItem "Peter"
.AddItem "Vanessa"
End With
End Sub