I've written this code into the click event of a command button but I get a Compile Error: Argument not optional.
What am I doing wrong. I am wanting to import a labor file to input the hrs worked by each employee into my spreadsheet. The filters are set up only because I'm not sure of the labor file name quite yet and just want the code to work first.
'Set up list of file filters
Filter = "Text Files (*.txt),*.txt," & _
"Lotus Files (*.prn),*.prn," & _
"Comma Separated Files (*.csv),*.csv," & _
"ASCII Files (*.asc),*.asc," & _
"All Files (*.*),*.*"
'Display *.* by default
FilterIndex = 5
'Set the dialog box caption
Title = "Select a File to Import"
'Get the filename
Filename = Application.GetOpenFilename(Filter, _
FilterIndex, Title)
'Exit if dialog box canceled
If Filename = False Then
MsgBox "No file was selected!"
Exit Sub
End If
'Open the file
Workbooks.Open FileName
Thanks,
What am I doing wrong. I am wanting to import a labor file to input the hrs worked by each employee into my spreadsheet. The filters are set up only because I'm not sure of the labor file name quite yet and just want the code to work first.
'Set up list of file filters
Filter = "Text Files (*.txt),*.txt," & _
"Lotus Files (*.prn),*.prn," & _
"Comma Separated Files (*.csv),*.csv," & _
"ASCII Files (*.asc),*.asc," & _
"All Files (*.*),*.*"
'Display *.* by default
FilterIndex = 5
'Set the dialog box caption
Title = "Select a File to Import"
'Get the filename
Filename = Application.GetOpenFilename(Filter, _
FilterIndex, Title)
'Exit if dialog box canceled
If Filename = False Then
MsgBox "No file was selected!"
Exit Sub
End If
'Open the file
Workbooks.Open FileName
Thanks,