Hi
I have code that will open a text file (don't know the name it will be but will be the only one), but I need to figure out how to get that file name so that I can use it to close the file later on.
After I copy the data over to the Current.xlsm file, I want to go BACK to that text file and close it, but I can't figure out how without somehow extracting the name of the file while doing that opentext function...
thoughts??
I have code that will open a text file (don't know the name it will be but will be the only one), but I need to figure out how to get that file name so that I can use it to close the file later on.
Code:
Workbooks.opentext Filename:="*.txt", Origin:= _
xlMSDOS, StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote _
, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, Comma:= _
False, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), Array(2, 1) _
, Array(3, 1)), TrailingMinusNumbers:=True
Range("A2:C9").Select
Selection.Copy
Windows("Current.xlsm").Activate
Sheets("Current Work").Select
Range("A1").Select
ActiveSheet.paste
After I copy the data over to the Current.xlsm file, I want to go BACK to that text file and close it, but I can't figure out how without somehow extracting the name of the file while doing that opentext function...
thoughts??