Consulting

Results 1 to 2 of 2

Thread: Help with VBA Combo Box code in a word document

  1. #1

    Help with VBA Combo Box code in a word document

    Hi there,

    I have created a simple combo box macro in the attached word doc, the reason being the text characters I intend to use exceed the maximum allowed per regular drop-down lists.

    I'm having an issue whereby the options in the list are duplicating, sometimes there are the correct number of options but I find particularly after clicking save the drop-down options become duplicated.

    I am very new to VBA so I'm sure that I'm missing something fundamental here, any help or advice would be ,massively appreciated.

    The code I used is below:

    Private Sub ComboBox1_DropButtonClick()
    ComboBox1.AddItem "Option 1"
    ComboBox1.AddItem "Option 2"
    ComboBox1.AddItem "Option 3"
    ComboBox1.AddItem "Option 4"
    ComboBox1.AddItem "Option 5 "
    ComboBox1.AddItem "Option 6"
    ComboBox1.AddItem "Option 7"
    ComboBox1.AddItem "Option 8"
    ComboBox1.AddItem "Option 9"
    ComboBox1.AddItem "Option 10"
    ComboBox1.AddItem "Option 11"
    End Sub
    Attached Files Attached Files

  2. #2
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,334
    Location
    Private Sub ComboBox1_DropButtonClick()
      With ComboBox1
        .Clear
        .AddItem "Option 1"
        .AddItem "Option 2"
        .AddItem "Option 3"
        .AddItem "Option 4"
        .AddItem "Option 5 "
        .AddItem "Option 6"
        .AddItem "Option 7"
        .AddItem "Option 8"
        .AddItem "Option 9"
        .AddItem "Option 10"
        .AddItem "Option 11"
      End With
    End Sub
    Greg

    Visit my website: http://gregmaxey.com

Posting Permissions

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