easy way to show path

teiben

Registered User.
Local time
Today, 17:12
Joined
Jun 20, 2002
Messages
462
Long story short, I need to have a command button (using xp) open up a folder where pdf's are stored, so the user can search. (orginally I wanted a pdf to open, then I tried having explorer open, so this is my last idea

I've tried a lot of the code in the archieves but none work exactly.

For example:

Private Sub cmdExplore_Click()
Dim stAppName As String

'stAppName = "C:\Windows\explorer.exe"
'above open in a tree view with my Documents; no explorer anywhere to be found


Call Shell(stAppName, 1)

Exit_cmdExplore_Click:
Exit Sub

Err_cmdExplore_Click:
MsgBox Err.Description
Resume Exit_cmdExplore_Click


any ideas?
 
Frankly there is no easy way. Try this, Open a Form in Design view. Select ActiveX Control from Insert Menu, Find and insert Microsoft Common Dialog Control. Display the property sheet and change its Name to cmDialog1. Create a Label wide enough to show a lengthy path and change its name to lbldb. Create a Command Button at the right side of the Label, change it's Name to cmdBrowse and change the Caption to Browse.... The Name property of all the three controls are important. so name them properly. Copy the Following Code into the Form Module. Activate the Form and Click on the Browse... Command Button. If all goes well you will see the Normal Dialog control that we see when we select File --> Open. Select a File you prefer from any location and click Open. That file Name should appear with the Path into the Label control that we have created.

Private Sub cmdBrowse_Click()
On Error GoTo ErrHandler
Dim VFile As String, xx As Integer, l As Integer
Dim msg As String, resp As Integer, lf As String

lf = vbCr

'Me!lblInput.Caption = ""
'Me![txtOutput] = ""

ChDrive ("C")
ChDir ("C:\")

cmDialog1.Filter = "All Files (*.*)|*.*|Text Files (*.txt)|*.txt|Excel WorkBooks (*.xls)|*.xls"

cmDialog1.FilterIndex = 1

cmDialog1.Action = 1

If cmDialog1.FileName <> "" Then
VFile = UCase(cmDialog1.FileName)

Me!lbldb.Caption = VFile
Me![db] = VFile
Me![grp] = Null
End If

ErrHandler:
Exit Sub

End Sub

I made little modification to the code to make it simple, but it should work.


visit my site http://msaccessblog.blogspot.com

good luck

apr pillai
 
Have a look at the attached sample;

1 For both word and pdf make sure you open the tables and change the location and name of your files.

2 Make sure that you change this to suit (it is behind the "Open PDF" button;
Code:
strAcPath = "C:\Program Files\Adobe\Acrobat 7.0\Acrobat\Acrobat.exe"
 

Attachments

Thanks for all the time to help me - greatly appreciated.

I tried to insert Microsoft Common Dialog Control, and it's telling me I don't have the license required to use this active x control. I searched on how to install it and its says to select "register". THere is no dialog box for this.

Like your site.
 
There's a better way to browse to a file without using an ActiveX control. Using ActiveX controls can make your life a living hell, so use them with extreme caution. I prefer to avoid them whenever possible.

Try out GHudson's sample here:
http://www.access-programmers.co.uk/forums/attachment.php?attachmentid=14926&d=1158873794

and see if this wouldn't work better for you. It's best to avoid ActiveX controls which may cause you reference errors on other people's computers. Also, the Common Dialog control is ONLY available to users who have VB installed, or a Developer Edition of Access. It isn't available on users machines generally and that makes extra problems for you.
 
Probably a bit of overkill but the attachment will do a search for the file type specified and you can open it with a double click.

Regards,
Chris.
 

Attachments

You rock!!!!!!!!!!!!! I tried the form fFindOpenImportfile form and I was actually able to see a pdf and open it.

It works in 2003, do you think I could use the code in 97?

I totally agree with the Active X thing. One other database I had created in a multiuser environment, I ran into the default user not even having the Calendar Control install, it ended up being a big pain in the butt....

Thanks again
 
If the version I linked to doesn't work in 97 (it should as he converted it FROM 97 for that thread), do a search here as it has references to it many times.
 

Users who are viewing this thread

Back
Top Bottom