View Single Post
 
Old 05-24-2011, 12:16 AM
ilkks ilkks is offline Windows Vista Office 2007
Novice
 
Join Date: May 2011
Posts: 23
ilkks is on a distinguished road
Default Code to export value from ComboBox

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
Reply With Quote