Solved

Get file path using dialog open box

Posted on 2007-11-28
3
4,216 Views
Last Modified: 2013-11-28
I'm using MS Access VBA and would like to open a dialog open box, similar to MS Excel's "GetOpenFileName" function for the user to select a specific file.  I then would like to capture the complete path and store it in a local table.  My code is below, though I'm not sure why MS Access is not understanding FileDialog function:

Dim dlgOpen As FileDialog

Set dlgOpen = Application.FileDialog(FileDialogType:=msoFileDialogOpen)

With dlgOpen
    .AllowMultiSelect = False
    .Show
End With

Thanks,
Vishalarya
0
Comment
Question by:vishalarya
  • 2
3 Comments
 
LVL 33

Accepted Solution

by:
roos01 earned 500 total points
ID: 20371591
Hello Vishalarya,

you might try something like:
flname = Application.GetOpenFilename( _
    Title:="Please select any file from the folder that contains the data, then click Open.")
If flname = False Then Exit Sub


the variable "flname" contains the selecte filename including path, you can use this for your object.

I hope this works for you
regards,
Jeroen
0
 
LVL 47

Expert Comment

by:Wayne Taylor (webtubbs)
ID: 20371662
Hi vishalarya,

If you add a reference to MS Office (Tools > References), you can use that code, then get the selected path from the SelectedItems property....

    Dim dlgOpen As FileDialog
    Set dlgOpen = Application.FileDialog(msoFileDialogOpen)
    With dlgOpen
        .AllowMultiSelect = False
        .Show
        MsgBox .SelectedItems(1)
    End With

Regards,

Wayne
0
 
LVL 47

Expert Comment

by:Wayne Taylor (webtubbs)
ID: 20371704
Umm, I thought this was for Access? GetOpenFilename doesn't work in Access.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now