Running Excel macros through DOS
Ramesh Narasimhan wrote...
Is it possible to run Excel through the DOS shell? -- I want to open up a
text file in Excel, run a Macro that rearranges and parses text, then save it
with a date-dependent name.
If you're really processing text, Excel is a poor tool to use. There
are many scripting languages that would be much easier to maintain and
run in console sessions. Windows even comes with two scripting
languages, VBScript and VJScript, which you could use to do this.
That said, you could create a workbook containing the code necessary to
process your text files in that workbook's Workbook_Open event handler.
Then run Excel using CMD.EXE's start command with command line
arguments for the text file to process and this workbook. Something
like
start excel d:\test\sample.txt d:\test\process.xls
Note: the argument order is important. Put the pathname for the text
file first followed by the pathname for the workbook. That way the text
file will be open when the workbook loads and runs its Workbook_Open
event.
|