How do I pass a parameter from the command line?

Azerty99

New Member
Joined
Mar 3, 2009
Messages
38
Guys, How do I pass a parameter into Excel from the command line:
Something like

Code:
start excel test.xls(Workbook_Open(99))

or

Code:
start excel test.xls(99)

where 99 is the parameter which is passed to the open sub?

Code:
Private Sub Workbook_Open(comm as String)
    MsgBox comm
End Sub

Obviously I want to do more with the parameter. For now just to get it working in a msgbox is fine.

I found this on a search

MrExcelLink

But the answer suggested an input box. I need an automated facility as the run will be 12 iterations through the file, from a fixed parameter file.

Thanks

Excel 2003
Windows XP Professional
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
The final post in that thread contains the actual solution - not using InputBox.

The solution depends on how you're intending to start Excel. What command are you using and from where are you issuing it?
 
Upvote 0
The final post in that thread contains the actual solution - not using InputBox.

The solution depends on how you're intending to start Excel. What command are you using and from where are you issuing it?

Thanks Ruddles - will give this a go
 
Upvote 0
(Sorry tried to edit my last post - ther's a 10 minute time limit.....)

Except it doesn't work

Tried:

start excel test.xls 99

I get msgbox = 133016

it says it can't find 99.xls
 
Upvote 0
I just added this code to a workbook and opened it from Start > Run with this:-

excel f:\command_line_parameter.xlsm /123456

and it worked fine.

Where are you entering start excel test.xls 99?
 
Upvote 0
Code:
start excel test.xls /99
Doesn't work

Am working in a system with no direct access to the command line, and restricted access elsewhere

Code:
start excel test.xls
Opens Test OK

but of course this is not quite true as I cannot actually type this in anywhere. I have to run it from another application with indirect access to the command line.

But leave it, it was getting way too complex for what I was trying to do. Just thought it maybe a one line command in Windows which it obviously isn't
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,120
Members
451,399
Latest member
alchavar

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