Show a list of files in a specified directory with an command button

W

wilfried

I try to see the list of the files in a specified directory. I try to
do it with a ncommand button in a access form. Give the list of all the
files (word-documents and e-mails) in for instance the directory c:\My
documents/ examples
 
D

Doug Robbins - Word MVP

This function, posted by fellow MVP Jonathon West, will work in all versions
of Word from 97
onwards

Public Function BrowseFile() As String
With Dialogs(wdDialogFileOpen)
If .Display <> -1 Then
BrowseFile = ""
Else
BrowseFile = WordBasic.FileNameInfo$(.Name, 1)
End If
End With
End Function

It returns the full pathname of the selected file, and a blank string if no
selection is made.


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
W

wilfried

I thank you already for your answer. My knowledge of access (and VBA)
is not so good. Can you please insert the path 'c:\My documents/
examples" into your answer so that I can use your answer in my access
form with a command button.

Doug Robbins - Word MVP schreef:
 

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