Advertisement

There's no such thing as a stupid question, but they're the easiest to answer.
Login
Search

Advertisement

Search Search
Search for:
Tech Support Guy > > >

How to Populate Multiple ActiveX ComboxBoxes VBA


(!)

chrisball's Avatar
chrisball chrisball is offline
Computer Specs
Member with 1 posts.
THREAD STARTER
 
Join Date: Jul 2012
Location: Perth
Experience: Intermediate
06-Jul-2012, 12:11 AM #1
How to Populate Multiple ActiveX ComboxBoxes VBA
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..


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
Else
EndIf
i = i+1
EndIF
Loop
As Seen On

BBC, Reader's Digest, PC Magazine, Today Show, Money Magazine
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.


Tags
activex control, combobox, msword 2010, vba

(clock)
THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


WELCOME
You Are Using: Server ID
Trusted Website Back to the Top ↑