VBA Code for Defining Drop Down List 
Author Message
 VBA Code for Defining Drop Down List

Hi!

In follow up to the message I just sent, here's one, simple (??) question:

If I insert a Combo Box using the Control Box toolbar, what code do I
insert in the macro to simply tell Word:  when someone clicks on this
box, here's the list I want them to be able to choose from?

Thanks!

mary



Wed, 05 Jan 2005 03:19:13 GMT  
 VBA Code for Defining Drop Down List
Hi Mary,

If you know all the items you want in the list to start with, then you can
put code something like this into the Initialize event of the UserForm.

ComboBox1.List = Array("Apples", "Oranges", "Bananas", "Peaches")

If you want to add or remove items while the UserForm is open, then take a
look at the AddItem and RemoveItem methods.

--
Regards
Jonathan West - Word MVP
MultiLinker - Automated generation of hyperlinks in Word
Conversion to PDF & HTML
http://www.multilinker.com
Word FAQs at http://www.multilinker.com/wordfaq
Please post any follow-up in the newsgroup. I do not reply to Word questions
by email


Quote:
> Hi!

> In follow up to the message I just sent, here's one, simple (??) question:

> If I insert a Combo Box using the Control Box toolbar, what code do I
> insert in the macro to simply tell Word:  when someone clicks on this
> box, here's the list I want them to be able to choose from?

> Thanks!

> mary



Wed, 05 Jan 2005 04:26:17 GMT  
 VBA Code for Defining Drop Down List
Hi, Jonathan!

Thanks for your reply!  Sounds pretty straightforward... but, silly
question, how do I get to the Initialize event of the userform?  In the
Visual Basic module, I chose Document from the left hand drop down box,
and New from the right hand drop down box, and then put in the code you
sent, but the list doesn't pop up when I click on the drop down box.

Can you please tell me what I'm doing wrong?

Thanks very much!!!

Mary

Quote:

> Hi Mary,

> If you know all the items you want in the list to start with, then you can
> put code something like this into the Initialize event of the UserForm.

> ComboBox1.List = Array("Apples", "Oranges", "Bananas", "Peaches")

> If you want to add or remove items while the UserForm is open, then take a
> look at the AddItem and RemoveItem methods.

> --
> Regards
> Jonathan West - Word MVP
> MultiLinker - Automated generation of hyperlinks in Word
> Conversion to PDF & HTML
> http://www.multilinker.com
> Word FAQs at http://www.multilinker.com/wordfaq
> Please post any follow-up in the newsgroup. I do not reply to Word questions
> by email



>>Hi!

>>In follow up to the message I just sent, here's one, simple (??) question:

>>If I insert a Combo Box using the Control Box toolbar, what code do I
>>insert in the macro to simply tell Word:  when someone clicks on this
>>box, here's the list I want them to be able to choose from?

>>Thanks!

>>mary



Sat, 08 Jan 2005 02:06:00 GMT  
 VBA Code for Defining Drop Down List
Hi Mary,

Ah, I have just noticed we were talking at cross-purposes. I was misled by
the fact that you posted into the UserForms group, about an item that
normally goes on a Userform. A Userform is a custom dialog that you can
build and display when a VBA macro is run, and the Initialize event is one
of the places on the Userform that you can include code.

However, reading more closely (which I should have done in the first
place!), I now see that you have put this dropdown list in the document
itself, which is rather a different proposition.

To be honest, I would recommend using controls from the Control Box in a
document at all. They aren't terribly stable, and wouldn't work at all if
somebody running Word for Macintosh opens the document

Much better is to use the dropdown formfield from the Forms toolbar. There
is an excellent set or articles by Dian Chapman on creating Word forms,
which covers everything much more comprehensively than I can in a newsgroup
answer. Take a look here

Please Fill Out This Form
Part 1: Create professional looking forms in Word
http://www.computorcompanion.com/LPMArticle.asp?ID=22

Part 2: Adding Automation to your Word forms.
http://www.computorcompanion.com/LPMArticle.asp?ID=46

Part 3: Learn more VBA (macros) to automate your forms.
http://www.computorcompanion.com/LPMArticle.asp?ID=119

Part 4: Use custom dialog boxes in your Word forms
http://www.computorcompanion.com/LPMArticle.asp?ID=127

Part 5: Connect your AutoForm to a database to save input time and keep
better records!
http://www.computorcompanion.com/LPMArticle.asp?ID=136

--
Regards
Jonathan West - Word MVP
MultiLinker - Automated generation of hyperlinks in Word
Conversion to PDF & HTML
http://www.multilinker.com
Word FAQs at http://www.multilinker.com/wordfaq
Please post any follow-up in the newsgroup. I do not reply to Word questions
by email


Quote:
> Hi, Jonathan!

> Thanks for your reply!  Sounds pretty straightforward... but, silly
> question, how do I get to the Initialize event of the userform?  In the
> Visual Basic module, I chose Document from the left hand drop down box,
> and New from the right hand drop down box, and then put in the code you
> sent, but the list doesn't pop up when I click on the drop down box.

> Can you please tell me what I'm doing wrong?

> Thanks very much!!!

> Mary


> > Hi Mary,

> > If you know all the items you want in the list to start with, then you
can
> > put code something like this into the Initialize event of the UserForm.

> > ComboBox1.List = Array("Apples", "Oranges", "Bananas", "Peaches")

> > If you want to add or remove items while the UserForm is open, then take
a
> > look at the AddItem and RemoveItem methods.

> > --
> > Regards
> > Jonathan West - Word MVP
> > MultiLinker - Automated generation of hyperlinks in Word
> > Conversion to PDF & HTML
> > http://www.multilinker.com
> > Word FAQs at http://www.multilinker.com/wordfaq
> > Please post any follow-up in the newsgroup. I do not reply to Word
questions
> > by email



> >>Hi!

> >>In follow up to the message I just sent, here's one, simple (??)
question:

> >>If I insert a Combo Box using the Control Box toolbar, what code do I
> >>insert in the macro to simply tell Word:  when someone clicks on this
> >>box, here's the list I want them to be able to choose from?

> >>Thanks!

> >>mary



Sat, 08 Jan 2005 03:16:29 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. VBA code to go to a bookmarked drop down goes to wrong drop down

2. Drop Down List Box - Drop Down portion does not always disappear after Click event

3. Code to drop down list on userform

4. Drop-down list in a list view

5. List of servers in VB for a drop down list

6. Press F1 key while drop-down menu item highlighted, drop-down menu stays on top

7. Max 65536 rows in drop-down list (Access)

8. Getting a drop down resource list when filtering by resource and date range

9. Disable IE5.5 drop down list when I type text within a web page - PLEASE HELP

10. Drop Down List in a field

11. X-Posted: Can I create a drop down list that will let me select an item

 

 
Powered by phpBB® Forum Software