Get the filename

  • Thread starter Thread starter Christer
  • Start date Start date
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
 
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
 
Back
Top