Please what is wrong with this code? Sometimes it works and sometimes (most of the time) it does not. What am I missing.
I want to open a text file that is store on the R Dirve in a folder called New Data. There are several files in this folder, each month a new file with a new name will be added, so I what the user to select the correct file from the New Data folder
Thanks
L.
Dim myfile
ChDrive "R"
ChDir "R:\month\December 2005\New Data\ *.txt"
myfile = Application.GetOpenFilename(filefilter:="Text Files (*.txt),.txt", MultiSelect:=True)
For x = LBound(myfile) To UBound(myfile)
Workbooks.OpenText Filename:=myfile(x), Origin:=xlWindows _
, StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, Comma:=False _
, Space:=False, Other:=False, FieldInfo:=Array(1, 2)
Next
I want to open a text file that is store on the R Dirve in a folder called New Data. There are several files in this folder, each month a new file with a new name will be added, so I what the user to select the correct file from the New Data folder
Thanks
L.
Dim myfile
ChDrive "R"
ChDir "R:\month\December 2005\New Data\ *.txt"
myfile = Application.GetOpenFilename(filefilter:="Text Files (*.txt),.txt", MultiSelect:=True)
For x = LBound(myfile) To UBound(myfile)
Workbooks.OpenText Filename:=myfile(x), Origin:=xlWindows _
, StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, Comma:=False _
, Space:=False, Other:=False, FieldInfo:=Array(1, 2)
Next