How to run a excel macro from commandline or thru .bat batch

nganesan

New Member
Joined
Mar 21, 2002
Messages
2
Hi people,

Is there a way of running excel macro from command line or using .bat ( batch file or operating system script file ).

I want to write a batch file which converts text file into excel file with certain columns protected and store it in new file name.

Can it be done from dos/windows/unix command prompt without invoking MS-Excel by double clicking?

Thanks in advance,

-N
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Reply, I don't believe this is possible. It is possible to run a commandline instruction or a batch file from Excel if that's any help to you.
 
Upvote 0
I need excel macro to be executed from command line. ( not command line from excel ).

Will this work?!
i)save a text file with .xls extension
ii) write a macro, put it as part of file which should run automatically when user opens the file.

ideas welcome.. thanks and appreciate your suggestions
 
Upvote 0
Running the Excel sheet from the command line and starting the macros from the "Worksheet_Open" event would work, but with one snag.

You will be prompted to enable or disable macros when the workbook opens. There are two known ways to bypass this.

1. Lower the security of Excel on the Tools|Macros|Security menu. (This is not recommended by anyone as your susceptible to malicious macros)

2. Become a "trusted source" for the users using Digital Signatures. I haven't used these and you'll need to check XL help or microsoft.com for how to use this. (people on this board are wary of digital signatures as well)

HTH
 
Upvote 0
I've been wondering about this too. My sheet has to be able to be opened without running the macro, too, though.

One trick might be to have the batch file create a dummy file on c: root, then have the Excel function check if that file exists. If it does, then it is meant to auto execute that particular function (or perhaps one of many depending on the name of the file). Then the batch file deletes the file after excel.exe exits.

Whether the function modifies the spreadsheet requiring a save, and how to automate the save I don't know (yet).

Any more clever ideas on how to do this?
 
Upvote 0

Forum statistics

Threads
1,213,543
Messages
6,114,236
Members
448,555
Latest member
RobertJones1986

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top