Getting the Command Line Arguments

127 views
Skip to first unread message

Shengxi Wang

unread,
Apr 20, 2017, 12:09:50 PM4/20/17
to Excel-DNA
Hello,

I'm currently developing an excel add-in using Excel-DNA for my company. For automation purpose, there is a need to pick up the command line argument when start an excel file from the command line. For example "start excel sample.xlsm argument1". One use case would be: the user can schedule the same file at different times with different arguments, so they can automate different things to the file at different times. Can anybody please let me know if there are any methods in Excel-DNA to pick up the command line arguments?

Thanks,
Shengxi

Fabian

unread,
Apr 24, 2017, 3:35:35 PM4/24/17
to Excel-DNA
Hi,

this is untested, but I would try:

1. Getting a hold of Excel's Process
2. Querying the command line arguments for that process

For #1, not sure if there's a more direct way, but ExcelDna provides you Excel's window handle / Hwnd, which you can use to get the process id (e.g. http://stackoverflow.com/questions/18184654/find-process-id-by-windows-handle )

Govert van Drimmelen

unread,
Apr 24, 2017, 3:47:20 PM4/24/17
to exce...@googlegroups.com
Just use the Environment.CommandLine property ?

-Govert
--
You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to exceldna+u...@googlegroups.com.
To post to this group, send email to exce...@googlegroups.com.
Visit this group at https://groups.google.com/group/exceldna.
For more options, visit https://groups.google.com/d/optout.

Shengxi Wang

unread,
May 8, 2017, 11:57:51 AM5/8/17
to Excel-DNA
Hi Govert,

Sorry about the late reply. I have implemented the Environment.CommandLine property. Exactly what I need. Thanks.
Reply all
Reply to author
Forward
0 new messages