Command Line summoning of a VB function

F*SH

New Member
Joined
Jul 5, 2006
Messages
39
Hi all

I'm trying to work out a command-line function (ie shell command) that'll open an Excel spreadsheet and run a macro with arguments. Opening Excel is easy enough, as is opening a specific spreadsheet. There is also a way to run a specific macro within the sheet.

But what stumps me is how to pass arguments. Any ideas? I basically need my spreadsheet (or rather a subroutine in it) to run from a batch file, with a different set of parameters each time.

Cheers!
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Why do you need to use a batch file?

Can't you use VBA to do what you want?
 
Upvote 0
Design requirement. I say a batch file, I actually lie. Partially. it's a cron job, designed to trigger the code (via a batch file) once a day. We don't want to keep Excel open and a script running all day long so some manner of automated, command-line implementation is sort of needed.
 
Upvote 0
Could you store the parameters in a text file of some sort and have the VBA read the values from there?
 
Upvote 0
Yeah, I guess that's a possibility. But it seems long winded somehow - I'm pretty sure there must be a way in invoke such a command more easily. Microsoft have been pushing inter-program operability so it would appear strange to me that there is no way to pass arguments from the most basic interface...
 
Upvote 0
F*sh

Curious if you worked this out---(Passing arguments)

Also can you post an example of your command line code/technique to get a specific VBA to run?

Thanks!
 
Upvote 0

Forum statistics

Threads
1,213,563
Messages
6,114,329
Members
448,564
Latest member
ED38

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