I've looked through several posts and tried this several different ways, but I still can't get it to work. It keeps telling me that the file (Y5533.PRN) could not be found. Any help would be greatly appreciated. This is the situation:
I have a "Main" tab and a "File Locations" tab. The user types in a file number and a code on the "Main" tab. Then the code and the file number are put together in the "File Locations" tab to create the file name. So if on the "Main" tab, the user enters file number 5533 in cell N4 and code Y in cell N5, then on the "File Locations" tab in cell I1, they are concatenated along with the file extension to create file name Y5533.PRN. I have the path typed in cell E1 on the "File Locations" tab, the user does not change this. I want to open the text file Y5533.PRN or whatever the filename in I1 happens to be. My workbook is on my desktop, but the files that I am opening are in C:\tire\workfil\dat (which is stored in cell E1). This is the first part of my code:
Sub Open_Files()
'
' Open_Files Macro
' Macro recorded 10/24/2008 by Terri Markle
'
'
Sheets("File Locations").Select
FilePath = Range("E1")
PRNfile = Range("I1")
Workbooks.OpenText Filename:=FilePath & "\" & PRNfile _
, Origin:=437, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, Semicolon:=False _
, Comma:=True, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), _
Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1), Array(8, 1), _
Array(9, 1), Array(10, 1), Array(11, 1), Array(12, 1), Array(13, 1), Array(14, 1), Array(15 _
, 1), Array(16, 1), Array(17, 1), Array(18, 1), Array(19, 1), Array(20, 1), Array(21, 1), _
Array(22, 1), Array(23, 1), Array(24, 1), Array(25, 1), Array(26, 1), Array(27, 1), Array( _
28, 1), Array(29, 1), Array(30, 1), Array(31, 1), Array(32, 1), Array(33, 1), Array(34, 1), _
Array(35, 1), Array(36, 1), Array(37, 1), Array(38, 1), Array(39, 1), Array(40, 1), Array( _
41, 1), Array(42, 1), Array(43, 1), Array(44, 1), Array(45, 1), Array(46, 1), Array(47, 1), _
Array(48, 1), Array(49, 1), Array(50, 1), Array(51, 1), Array(52, 1), Array(53, 1), Array( _
54, 1), Array(55, 1), Array(56, 1), Array(57, 1), Array(58, 1), Array(59, 1)), _
TrailingMinusNumbers:=True
I have a "Main" tab and a "File Locations" tab. The user types in a file number and a code on the "Main" tab. Then the code and the file number are put together in the "File Locations" tab to create the file name. So if on the "Main" tab, the user enters file number 5533 in cell N4 and code Y in cell N5, then on the "File Locations" tab in cell I1, they are concatenated along with the file extension to create file name Y5533.PRN. I have the path typed in cell E1 on the "File Locations" tab, the user does not change this. I want to open the text file Y5533.PRN or whatever the filename in I1 happens to be. My workbook is on my desktop, but the files that I am opening are in C:\tire\workfil\dat (which is stored in cell E1). This is the first part of my code:
Sub Open_Files()
'
' Open_Files Macro
' Macro recorded 10/24/2008 by Terri Markle
'
'
Sheets("File Locations").Select
FilePath = Range("E1")
PRNfile = Range("I1")
Workbooks.OpenText Filename:=FilePath & "\" & PRNfile _
, Origin:=437, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, Semicolon:=False _
, Comma:=True, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), _
Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1), Array(8, 1), _
Array(9, 1), Array(10, 1), Array(11, 1), Array(12, 1), Array(13, 1), Array(14, 1), Array(15 _
, 1), Array(16, 1), Array(17, 1), Array(18, 1), Array(19, 1), Array(20, 1), Array(21, 1), _
Array(22, 1), Array(23, 1), Array(24, 1), Array(25, 1), Array(26, 1), Array(27, 1), Array( _
28, 1), Array(29, 1), Array(30, 1), Array(31, 1), Array(32, 1), Array(33, 1), Array(34, 1), _
Array(35, 1), Array(36, 1), Array(37, 1), Array(38, 1), Array(39, 1), Array(40, 1), Array( _
41, 1), Array(42, 1), Array(43, 1), Array(44, 1), Array(45, 1), Array(46, 1), Array(47, 1), _
Array(48, 1), Array(49, 1), Array(50, 1), Array(51, 1), Array(52, 1), Array(53, 1), Array( _
54, 1), Array(55, 1), Array(56, 1), Array(57, 1), Array(58, 1), Array(59, 1)), _
TrailingMinusNumbers:=True