Excel 2003: open spreadsheet and run macro from command line

3

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?

petermolnar

Posted 2011-04-04T08:18:13.417

Reputation: 213

Answers

2

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'.

Gaff

Posted 2011-04-04T08:18:13.417

Reputation: 16 863