Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

combo box and WORD

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
Hello, i have what i think would be a very simple question but i am having problems finding any help. What i would like to do is on a form have a combo box which lists several letters that a the user can select. I would like a command button to then open the WORD document that was selected in the combo box. Any ideas?? Thanks for the help. w.
 
You'll need to do a bit of programming to achieve this. If you want a hand with the actual code, e-mail me, but the basic method is as follows:

First you need a userform containing a combo box (actually, a listbox would be OK). In the Form_Initialize event (which runs when the form starts up) you place the code which will load up the names of the documents. To do this you need to have either a static list, such as a text file, containing all the document names (which you'll access using the Open "C:\MyFile" For Input As ... commands), or else you need to interrogate a directory where all the documents are kept (using the Dir command).

Either way, you need to write a loop which will go through all available options and then load them into the Listbox control using the Listbox.AddItem event.

Having got the names into the listbox, you can code either the ListBox.DblClick Event or a separate Command Button to open the document. The way this works is by using the ListBox.Selected property - you get the information relating to the highlighted item in the ListBox and pass it to a variable, e.g. "Newdoc". You then pass Newdoc to the following:

Documents.Add Template:=NewDoc, NewTemplate:=False

Good luck!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top