# Excel 2003: open spreadsheet and run macro from command line

The need: run a macro within an excel 2003 file every week, automatically, than save the file.

The approach: add an action to task manager for every week, calling the file with command line parameters.

The problem: what parameters are need to be called and how to start a macro from command line? Is it even possible?

-

You could do this with VBScript. Here's some example code:

Option Explicit
Dim excelObject

Set excelObject = CreateObject("Excel.Application")
excelObject.WorkBooks.Open "path:\to\file.xls", 0, True
excelObject.Run "MacroName"
excelObject.Quit

Set excelObject = Nothing


Paste that into a file with extension .vbs and running that script should open the desired spreadsheet in Excel, running the macro with name 'MacroName'.

-