I tried using the built-in drop down list function to store a list of 36
names, but received an error stating it could only hold 25. So I have added
a VBA ComboBox, but how can I load the data in when the document is first
loaded?
I tried:
Sub AutoNew()
ComboBox1.AddItem "Name 1"
ComboBox1.AddItem "Name 2"
ComboBox1.AddItem "Name 3"
ComboBox1.AddItem "Name 4"
End Sub
Any help would be appreciated.
John
vaportrailsf - 20 Apr 2005 20:15 GMT
On a different thread someone posted this link which i think will help you.
http://support.microsoft.com/default.aspx?scid=kb;en-us;253542
> I tried using the built-in drop down list function to store a list of 36
> names, but received an error stating it could only hold 25. So I have added
[quoted text clipped - 12 lines]
>
> John
Dian D. Chapman, MVP - 22 Apr 2005 23:38 GMT
Close, but you need to add the code into the UserForm#_Initialization
event. This way when the dialog box is initialized (prepares to open)
it will run various events to do whatever you need to "prepare" the
information...one of which will be to load the combo box with your
list.
Double click on your UserForm to go into that code module and click
the left drop down in the code and choose USERFORM. Then...on the
right side drop down, you'll see the available events for the
form...one will be initialize. Add your ComboBox1.AddItem "Name 1"
codes into that event.
Then, of course, you'll need to call the dialog box to display...which
can be done by calling UserForm1.Show (or whatever your dialog box is
called) in the location where you'll need the form to display. If you
want it displayed when a new document is created from your form
template...put the show code into the ThisDocument_New procedure.
Hope this helps...
Dian D. Chapman, Technical Consultant
Microsoft MVP, MOS Certified
Editor/TechTrax Ezine
Free MS Tutorials: http://www.mousetrax.com/techtrax
Free Word eBook: http://www.mousetrax.com/books.html
Optimize your business docs: http://www.mousetrax.com/consulting
Learn VBA the easy way: http://www.mousetrax.com/techcourses.html
>I tried using the built-in drop down list function to store a list of 36
>names, but received an error stating it could only hold 25. So I have added
[quoted text clipped - 12 lines]
>
>John