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

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,367
Office Version
  1. 365
Platform
  1. Windows
Why do you need to use a batch file?

Can't you use VBA to do what you want?
 
Upvote 0

F*SH

New Member
Joined
Jul 5, 2006
Messages
39
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

Seti

Well-known Member
Joined
May 19, 2002
Messages
2,916
Could you store the parameters in a text file of some sort and have the VBA read the values from there?
 
Upvote 0

F*SH

New Member
Joined
Jul 5, 2006
Messages
39
ADVERTISEMENT
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

cgmojoco

Well-known Member
Joined
Jan 15, 2005
Messages
699
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,196,027
Messages
6,012,954
Members
441,740
Latest member
abaz21

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
Top