Link to home
Start Free TrialLog in
Avatar of yitz99
yitz99

asked on

Using Office.FileDialog, or alternative

Hi there Access Gurus,

I am wondering if it is possible to user the Office.FileDialog component with late binding.  The reason for this is that the application is distributed to Access 2000 and XP users.  If 2000 users hit the 'browse' button, then I will just flash an error message saying "this don't work with 2k", when it kacks at the "createobject" line.  If I use early binding, then it won't compile at all under 2k.  

All the examples that I have run across use early binding, and the code below doesn't work.

  Dim fDialog As Object    
  Set fDialog = CreateObject("Office.FileDialog")

Better yet, does anyone have a class module that I can plug in that will work on 2k or XP?
ASKER CERTIFIED SOLUTION
Avatar of Emanon_Consulting
Emanon_Consulting

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Emanon_Consulting
Emanon_Consulting

OK so the code I just pasted will call the FilePicker across any version of Access.
It's really simple to use. After you select the file path etc... it gets stored in the variable called 'GetOpenFile'

Let's say you have a form with a text field on it and the field name is "txtFilePath"
Now a command button called "cmdGetFilePath"

In the On Click event of the command button just paste this code.

Private Sub cmdGetFilePath_Click()

    txtFilePath = GetOpenFile
   
End Sub


This will call the Function and store the file path in the field.  It's that simple.

Let me know how it works or if you have any more questions...
Cheers
Michael
Avatar of Gustav Brock
Sounds like you wish to open a dialog box with folder/file display and pick a filename?

If so, an API call is the safest route.
Go and get a class module which wraps it all nicely with minimum amount of code:

  http://www.kpries.de/entwicklertools.htm#filedialog

It's in German but you can easily find out. It contains full examples.

/gustav
Avatar of yitz99

ASKER

Fast, pleasant service, at a very reasonable price! ;)
thanks and stay healthy!
My pleasure yitz99,

Happy Databasing!

Cheers
Michael
Michael,
This is a good example and nice writeup to explain the codes. Keep it up.
Bill