accessing the Windows Open-File window in MS Access

Soton

Registered User.
Local time
Today, 23:41
Joined
Mar 17, 2008
Messages
17
In Excel, I can use code like 'tempstring = Application.GetOpenFilename("(xls),*.xls", , "Open File")' to browse for a filename in any folder and return it to Excel in variable 'tempstring'. I would like to do something similar in Access but cannot find the commands to access the Open-file window. The only articles I have seem, require the folder path to be hard coded.

I am trying to create a hyperlink to the file and store it in a table, along with other data.

Any ideas. Please keep it simple as I am no expert
 
Yes you can but it does require some understanding of coding sorry.... I used the method in the attached sample DB but you have to make sure that the appropriate Microsoft Office Library is selected in the references as the FileDialog object works only if you include a reference to the Office library.

Anyway give it a look can't remember where I orginally got the code but if your out there Thanks :) just adjusted to my needs at the time.

Open the form and click add files this opens the FileDialog (if you get a runtime error check references "alt F11>Tools>References" Microsoft Office XX.X Object Library needs to be selected) if more than one available check the box and retry)

When selected this is passed to public function which you will find in modules section.

Hope it helps John :)
 

Attachments

Many Thanks. Have had a quick look and it does what I was looking for. Only need to incorporate it into my database now:)
 
Have managed to get it working with my database - only had to add a reference.

On a similar topic, is there a way to open a dialogue box and save the path to a folder rather than an individual file. For example, you might have different folders for different sets of images or music files and want to link to the parent folder rather than all the individual files.
 
the filedialog you are using probably does it - it probably just needs a flag of some sort to indicate use "save" mode rather than "open" mode - there are generaly numerous flags available ie allowchangefolder, allowchangefiletype, ignoreoverwrite etc etc so you probably need to see an example of the correct usage

if not, i have seen exanples of folderpickers, that dont actually save files, just navigate to a given folder, and return the folder name.
 
The folderpicker sounds just what I want - I just need to collect the foldername.

Do you know of any links
 

Users who are viewing this thread

Back
Top Bottom