Get the filename

C

Christer

I want to automate import of textfiles which have different names each time.
How do I let the user select file and use that in my code? In Excel I can use
GetOpenFilename, what is the equivalent in Access.

Christer
 
X

XPS350

I want to automate import of textfiles which have different names each time.
How do I let the user select file and use that in my code? In Excel I can use
GetOpenFilename, what is the equivalent in Access.

Christer

You can use a code like below to do this.

Dim Path As String
Dim FileName As String

Path = "C:\"

With Application.FileDialog(3)
.Title = "Select a file"
.Filters.Add "Textfiles", "*.txt"
.AllowMultiSelect = False
.InitialFileName = Path
If .Show <> 0 Then
FileName = .SelectedItems.Item(1)
<your actions>
End If
End With

Groeten,

Peter
http://access.xps350.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top