How do I display external files to a dropdown list?

S

SleeplessTexas

I'm attempting to use an unbound control's data source to list (*.docs or
*.mpeg) files from a static path, and once displayed, the AfterUpdate
argument would launch the application based upon the file's extension.
 
A

Allen Browne

To list all the files in a folder into a combo box, copy the code from this
link into a module:
http://members.iinet.net.au/~allenbrowne/func-02.html

Change this line, depending on where your folder is and what fiiles you want
to read:
strFileName = Dir$("C:\MyFolder\*.doc")

Set this property for your combo:
RowSourceType DirListBox

The combo now lists the files of the specified type from the specified
folder.

To automatically launch the application designed to handle docs or mpegs or
whatever, use FollowHyperlink in the AfterUpdate event procedure of the
combo:

Private Sub Combo1_AfterUpdate()
If Not IsNull(Me.Combo1) Then
Application.FollowHyperlink Me.Combo1
End If
End Sub
 

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