Can you not put your code into the Workbook_Open event of an Excel file? Something like:
Private Sub Workbook_Open() [your routine name here] End Sub
HTH
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » Start Excel from command prompt (2002)
Edited by HansV to make URL clickable – see Help 19
I want to start excel from the command prompt, opening an .xls file and starting a macro.
Start Excel opening an .xls file is no problem: Excel.exe C:AO-LL.xls, that works.
I found in the knowledge base an article about the available switches: http://support.microsoft.com/?kbid=211481%5B/url%5D
The article doesn’t say anything about starting macro’s.
Does anybody know what to add to the commandline to start a macro?
Thanks for the quick reply.
The work-around is not possible in this case.
I do not want to run the macro when the excel workbook is opened.
I want to save one of the sheets as a csv file in a batch proces just before processing the csv file.
Knowing about the possibility to start Word from the command prompt running a macro I assumed the same being possible with Excel.
There are two approaches that I can think of:
1- Put your code in the Open event routine of the workbook in question. Dream up your own command line switch. Run Excel with the filename and your switch. In the Open event routine, have your code check the command line for your switch, and if it is not there do nothing. If it is there, create the .CSV file and exit Excel using Application.Quit.
2- Put your code into the Open even routine of another workbook. Run Excel specifing that workbook as the one to open. In the Open event routine, open the real workbook, create the .CSV file, and then exit Excel using Aplication.Quit.
There are two approaches that I can think of:
1- Put your code in the Open event routine of the workbook in question. Dream up your own command line switch. Run Excel with the filename and your switch. In the Open event routine, have your code check the command line for your switch, and if it is not there do nothing. If it is there, create the .CSV file and exit Excel using Application.Quit.
2- Put your code into the Open even routine of another workbook. Run Excel specifing that workbook as the one to open. In the Open event routine, open the real workbook, create the .CSV file, and then exit Excel using Aplication.Quit.
Thanks for the quick reply.
The work-around is not possible in this case.
I do not want to run the macro when the excel workbook is opened.
I want to save one of the sheets as a csv file in a batch proces just before processing the csv file.
Knowing about the possibility to start Word from the command prompt running a macro I assumed the same being possible with Excel.
Edited by HansV to make URL clickable – see Help 19
I want to start excel from the command prompt, opening an .xls file and starting a macro.
Start Excel opening an .xls file is no problem: Excel.exe C:AO-LL.xls, that works.
I found in the knowledge base an article about the available switches: http://support.microsoft.com/?kbid=211481%5B/url%5D
The article doesn’t say anything about starting macro’s.
Does anybody know what to add to the commandline to start a macro?
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.