Fill choices in combo box from a directory of documents

M

magicdds

I have the following code:

Private Sub Command0_Click()

Dim strDirPath As String
Dim strOutDocName As String
Dim strDir As String
Dim strDirEntry As String

' strDirPath is a Function that Gets the path to the Microsoft Word Directory

strDirPath = DirToPath("word\", False)
strDir = strDirPath & "*.doc"

strDirEntry = Dir(strDir)

Do While strDirEntry <> ""
MsgBox strDirEntry
strDirEntry = Dir
Loop

End Sub


When I click on a button in my form , the code above runs and message boxes
pop up printing out each document in the Word directory. I would like to
populate the choices in a combo box on the form with each of these documents,
so I can click on the document thayt I want to print.

How can I populate the combo box with the list of documents instead of
displaying them with the Msgbox command?

Thanks
Mark
 
D

Damon Heron

check out help for combobox.additems....
Here is a function to add items to a combobox set to value list:

Function AddItemToBeginning(ctrlComboBox As ComboBox, _
ByVal strItem As String)

ctrlComboBox.AddItem Item:=strItem, Index:=0

End FunctionDamon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top