View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Gary Brown Gary Brown is offline
external usenet poster
 
Posts: 178
Default Retrieve Access database Path and File name

'/=====================================/
Sub TestOpen()
Dim f1 As String

With Application.FileDialog(msoFileDialogFolderPicker)
If .Show = False Then Exit Sub
f1 = .SelectedItems(1)
End With

MsgBox "User Selected " & f1

End Sub
'/=====================================/

--
HTH,
Gary Brown

If this post was helpful to you, please select ''YES'' at the bottom of the
post.



"tenlbham" wrote:

Is there a way to navigate to and select a folder using a similar method, but
without having to pick a file within that folder?

I'd like my users to be able to navigate to a desired folder where a
standard set of files is located. The folder path would be returned as a
string and used to navigat to that standard file set in future operations.

Thanks!


"Charles Chickering" wrote:

Using the File dialogs does not open the files for you, it just give you a UI
for the user to pick the file from. After the file is selected you can do
what you want.

Sub TestOpen()
Dim f1 As String
With Application.FileDialog(msoFileDialogOpen)
.AllowMultiSelect = False
.InitialFileName = "C:\YourDefaultFolder"
.Filters.Clear
.Filters.Add "Database Files", "*.mdb"
.FilterIndex = 1
If .Show = False Then Exit Sub
f1 = .SelectedItems(1)
End With
MsgBox "User Selected " & f1
End Sub

--
Charles Chickering

"A good example is twice the value of good advice."


"JT" wrote:

I have a macro that I want the user to select an Access database. I don't
want the macro / user to open it with a dialog box. I would like them to use
something like a dialog box to navigate and select the item. Once it is
selected, my macro will strip of the file name and path where it is located.

Any suggestions or code to accomplish this? Thanks for the help.....
--
JT