ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel filename command line parameter to VB (https://www.excelbanter.com/excel-programming/313292-excel-filename-command-line-parameter-vbulletin.html)

mark

Excel filename command line parameter to VB
 
I'd like to execute a macro in Excel automatically using a
VB .exe file. I can do that, but would like to have the
VB file be generic so that it can just receive the
specific Excel file's name as a command line parameter.

Can someone show me how to receive that, in VB? An
example of which portion of the code starts to use it? I
don't think I'm wording this well... sorry.

Bob Phillips[_6_]

Excel filename command line parameter to VB
 
Mark,

In you program read the parameters using the "Command" function.

Sub Main()
Dim sParam As String

sParam = Command()
MsgBox "The parameters a " & sParam

End Sub

If you pass more than one parameter, e.g. myProj param1, param2, then you
can parse it to separate it out.

--

HTH

RP

"mark" wrote in message
...
I'd like to execute a macro in Excel automatically using a
VB .exe file. I can do that, but would like to have the
VB file be generic so that it can just receive the
specific Excel file's name as a command line parameter.

Can someone show me how to receive that, in VB? An
example of which portion of the code starts to use it? I
don't think I'm wording this well... sorry.




mark

Excel filename command line parameter to VB
 
Sub Main()
Dim sParam As String
sParam = Command()



Thanks, Bob. That's what I needed to know!



All times are GMT +1. The time now is 12:04 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com