Auto Open Macro of external .txt file based on cell reference

  • Thread starter Thread starter Tony D
  • Start date Start date
T

Tony D

Hello,
I want to create a template spreadsheet that upon opening will launch a macro that opens an external .txt file. I want the template to open a specific cell reference. The external .txt file is already delimited by tabs. Ifone were to do this manually (XL2010), upon opening the .txt file, Delimited is the default radio button that excel determines, click Next, Tab is already checkmarked, click Finish.

Example:
Cell A1 contains my full path and file name. Example: c:\path\test20120917.txt
Note today's date is Sep 17, 2012

Each day when I open this template, it will pull open a new file name referenced by A1 (ie. next days date - example- c:\path\test20120918.txt) Note tomorrow's date is Sep 18, 2012

Thank you very much in advance.
Tony
 
hi Tony,

MyFile = "c:\path\" & Year(Now) & Format(Month(Now), "00") & Format(Day(Now), "00") & ".txt"

Workbooks.OpenText Filename:=MyFile, Origin:=xlMSDOS, _
StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=True, Tab:=True, Semicolon:=False, Comma:=False, _
Space:=True, Other:=False, FieldInfo:=Array(Array(1, 1)), TrailingMinusNumbers:=True


--
isabelle



Le 2012-09-17 20:30, Tony D a écrit :
 
Back
Top