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"

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

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.