?
Solved

Excel.exe arguments

Posted on 2003-02-26
5
Medium Priority
?
1,704 Views
Last Modified: 2012-06-27
Hi all,
what is the command line to execute a macro in the command prompt?

>Excel.exe macro1 ?

Thanks
0
Comment
Question by:KCChan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 18

Expert Comment

by:Curt Lindstrom
ID: 8031318
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
0
 

Author Comment

by:KCChan
ID: 8031710
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

0
 
LVL 13

Accepted Solution

by:
cri earned 200 total points
ID: 8031821
You can...

See Longre's contribution in http://www.j-walk.com/ss/excel/eee/eee002.txt
0
 
LVL 3

Expert Comment

by:Moliere
ID: 8034745
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.
0
 

Author Comment

by:KCChan
ID: 8038428
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:

POWER PROGRAMMING TECHNIQUE

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

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question