Hi,
You are mixing up two methods of getting filenames.
The GetOpenfilename displays the folder view and returns the selected
filename, or False is none is picked.
The DIR command returns filenames that match a given search string, eg:
"C:\myfolder\*.xls"
Dim Filename As Variant
Filename = Application.GetOpenFilename
If Filename = False Then
MsgBox "No file selected"
Else
MsgBox "Process file " & Filename
End If
Cheers
Andy
--
Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
"Phil" wrote in message
...
Hi guys, I'm becoming increasingly frustrated with what I think is a
relatively simple procedure.
I am creating a process that requires the user to open a file (I'm not
sure
where it will be saved), and then the code will simply copy some data out
of
this selected file into the template document.
I currently have:
Public Sub ImportData()
Dim curfolder As String
Dim filename As String
Sheets("Sheet1").Select
Range("A1:ED1000").Select
Selection.ClearContents
Application.GetOpenFilename
filename = Dir(curfolder)
Workbooks.Open filename
Range("A1:ED1000").Select
Selection.Copy
However, when I reach the select file dialog box and select the necessary
file, the file I want isn't actually selected, but the first file in that
folder.
Can someone help me with this predicament please?
Thanks