I have MACROBUTTON, that launches UserForm, that contains ComboBox. What is the code to export chosen value from ComboBox to document as text.
I have this code:
Code:
Private Sub UserForm_Initialize()
With cboFood
.AddItem "Apple"
.AddItem "Pie"
.AddItem "Meat"
.AddItem "Squirrel"
.AddItem "Banana"
.AddItem "Nuts"
End With
End Sub
____________________________________
Private Sub cmdOK_Click()
With ActiveDocument
.Bookmarks("Food).Range.Text = cboFood.Value
End With
Application.ScreenUpdating = True
Unload Me
End Sub
And it exports the chosen value by updating it to the bookmark. It works, But I want it to be exported as text that overrides the MACROBUTTON.
I think the code that I am looking for is something like this:
Code:
Private Sub cmdOK_Click()
Selection.TypeText Text:="cboFood.Value"
Unload Me
End Sub