1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

How to Populate Multiple ActiveX ComboxBoxes VBA

Discussion in 'Software Development' started by chrisball, Jul 6, 2012.

Thread Status:
Not open for further replies.
  1. chrisball

    chrisball Thread Starter

    Jul 5, 2012
    I'm building a lengthy MSWord Document with numerous activeX comboboxes on it.

    There are a number of combo boxes which need to be populated with the same information, therefore I want to be able to give these a naming convention i.e. country1 country2 etc and then be able to iterise through a collection to populate the combox box with the same info. This will be run on open. Also as the document is dynamic, so on intial editing some of these comboboxes may be deleted prior to saving and closing. To ensure that when the document is open subsequently that no errors occur and if statement is also needed to check that the combobox exists before trying to populate the boxes.

    Given that the collections tend work on indexes. I was going to count the collection then iterise through the collection checking to see if a trimmed name match occurs and if so then populate. However it all seems to fail for me. Below is my code..

    dim i as integer
    dim shapesCount as integer 
    dim name as string
    dim fullName as string 
    shapesCount = ActiveDocument.InlineShapes.Count
    let i = 1
    name = left(ActiveDocument.InlineShapes(i).Title, 7)
    fullName = ActiveDocument.InlineShapes(i).Title
    Do while i < shapesCount
    If (combox exists) then
    If name = "country"
    With fullName
    .Additem "Australia"
    .AddItem "UK"
    .AddItem "US"
    .AddItem "Canada"
    End with
    i = i+1
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1059872