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


Tony D

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.

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.


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


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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question