Results 1 to 2 of 2
  1. #1
    Star Lounger
    Join Date
    May 2009
    Posts
    84
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have a simple combo box on a dialog box. How do I replace each drop-down value below with a short text string? For example, if "Red" was selected, "The car was red." is placed at a bookmark in the document. If "Blue" selected, "The car was blue." is placed in the document.

    Public Sub UserForm_Initialize()

    cboEmployee.AddItem "Red"
    cboEmployee.AddItem "Blue"

    End Sub

    Thanks,
    Charlie
    charlie6067

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts
    Try something like this. Note that this version removes the temporary bookmark so it is good for one use only but you didn't specify where the placeholder was in your document so this method just demonstrates one way.
    Code:
    Public Sub OKButton_Click()
      Dim str as String
      str = "The car was " & LCase(cboEmployee) & "."
       If ActiveDocument.Bookmarks.Exists("car") = True Then
          ActiveDocument.Bookmarks("car").Range.Text = str
       End If
    Andrew Lockton, Chrysalis Design, Melbourne Australia

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •