Excel.exe arguments

Hi all,
what is the command line to execute a macro in the command prompt?

>Excel.exe macro1 ?

Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

criConnect With a Mentor Commented:
You can...

See Longre's contribution in http://www.j-walk.com/ss/excel/eee/eee002.txt
Curt LindstromCommented:
Do you mean that you want to run a macro when you open the file?
If that is what you want to do you enter the macro as a workbook macro. Alt F11, double click "This workbook"
and enter code like,

Private Sub Workbook_Open()
Call MyMacro
End Sub

Where MyMacro is the macro you want to run.

Regards Curt
KCChanAuthor Commented:
i need the command line, or u can say it as a shell command to run a macro in an Excel file

In other words, i am trying to call and run the macro from DOS

This is a two step procedure.

1) In the workbook with the macro (located at C:\subdirectory\workbook.xls), set up an Auto_Open macro that will execute when the workbook opens. In that Auto_Open code, put the macro code or put the sub name for the macro code you want to run.

2) From the command line, type:
start excel C:\subdirectory\workbook.xls /e

The /e option opens Excel without the splash screen and blank workbook.

I hope this helps.
KCChanAuthor Commented:
Thanks Moliere, but i got the complete solution from the URL that cri has posted. This is one of the paragraph that i hav taken from there:


By Laurent Longre

There is a way for an auto-start macro to read the arguments on the
command line (with Excel 97).

Assume that you want to read the command line argumentsfrom an Auto_open
sub in the workbook "c:\temp\test.xls" opened by a batch file (or by a
Win95 shortcut).

Your command line should look like this one:

start excel c:\temp\test /e/param1/param2/.../paramN

i.e. : after excel.exe, the name of the workbook containing the
Auto_open, then the switch /e **immediately** followed by your own
arguments. These arguments should be separated by "/" and form a
continuous string without spaces.
All Courses

From novice to tech pro — start learning today.