Solved

Get file path using dialog open box

Posted on 2007-11-28
3
4,249 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 33

Accepted Solution

by:
Jeroen Rosink 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
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.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

733 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