Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do i run an excel macro from .bat file 1

Status
Not open for further replies.

kkohli

Programmer
Jun 22, 2001
3
US
How do i run an excel macro from .bat file
 
Hi kkohli,

To "accept the challenge", I just created a batch file using these steps (which work).

First, you ask... how do I "run" an Excel macro from a batch file, so I expect you know how to "create" batch files.

Step 1) - Determine which folder your "Excel.exe" file is located in. As you liekly know, you can do this by right-clicking on your Excel icon and checking the Properties.

It will likely be located in the following folder...
"C:\Program Files\Microsoft Office\Office\EXCEL.EXE"

Because batch files are run from DOS, you'll need to reference the "DOS" names for the location of the Excel.exe file.

For example, using the above location, you would use...
C:\progra~1\micros~1\office\excel.exe

Step 2) Do the same - determine the path (in DOS names) for the Excel ("xls") file that you want to load.

Step 3) In the batch file, combine the two lines, with a space between them. e.g.
C:\progra~1\micros~1\office\excel.exe c:\myfolder\excel\workbo~1\workbo~1.xls

I expect you'll know that the above has to be on ONE line in your batch file.

Step 4) After creating the batch file, you could also create a desktop shortcut for it.

Step 5) In the Excel file itself, create a "Workbook Open event" for running your macro when the file is opened.

I hope this helps. :) Please advise as to how you make out.

Regards, ...Dale Watson dwatson@bsi.gov.mb.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top