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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open folder to view specific files

Status
Not open for further replies.

BeallDon

Technical User
Aug 20, 2007
46
CA
I have a button on a form that, when clicked, will open an explorer winder to a specific directory where I have PDF files stored.

Code:
Private Sub ViewPDFFiles_Click()
Dim OpenPDFfolder As Variant, myPath As String
myPath = "C:\Documents and Settings\myPDFfolder"
If Dir(myPath, vbDirectory) <> "" Then OpenPDFfolder  = Shell("Explorer.exe " & myPath, 1)
End Sub

Each record on the form has it's own ClientNumber that is part of the name of each PDF file. Clients have multiple PDF files and all PDF files begin with Client # and then the ClientNumber for that record and more info after that (ie: Client #SIF2111JS - Smith, John; Invoice #123456).

I would like to be able to click the ViewPDFFiles button and have the explorer open up and ONLY show the PDF files for that specific ClientNumber.

How can I create a "filter" when I open explorer? I tried adding \Client #" & Me.ClientNumber & "*.*" to my path but that didn't work.

Any suggestions?
 
Windows explorer doesn't allow you to filter by file type or name (you can see this by navigating to a folder in Windows explorer and appending \filespec to the end of the path - eg C:\Documents and Settings\MyPDFFolder\*.pdf

Can I suggest as an alternative - you open a File/Open common control, filtered to only display the pdf files for that particular client (by setting an appropriate mask).
Advantage of that is that you can then have it open in Adobe Reader (or equivalent) as a follow up to clicking the Open button.

John
 
You can do this with the [blue]FileDialog[/blue] object. There is a lot of info in the MS Access VB Editor help files for it - at least with 2003 and 2007, I don't remember about prior versions.

You can set the default file name there to work as your filter. I have done this at least a couple of times.

--

"If to err is human, then I must be some kind of human!" -Me
 
Thank you very much jrbarnett and kjv1611 for your suggestions. I will look at each of those methods and will figure something out.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top