Command Line Arguments
I have an Excel Workbook that, when opened, runs a
particular macro. The macro requires a few arguments from the user, in order to run. Rather than have the user specify them as the macro is running, I'd like to have the user specify them when they open the Workbook (from the command line). Is there a way to specify command line arguments to Excel, and if so, how can I access them from a macro? Thanks. Michael |
Command Line Arguments
"Michael" wrote in message ... I have an Excel Workbook that, when opened, runs a particular macro. The macro requires a few arguments from the user, in order to run. Rather than have the user specify them as the macro is running, I'd like to have the user specify them when they open the Workbook (from the command line). Is there a way to specify command line arguments to Excel, and if so, how can I access them from a macro? Thanks. You cant use the command line arguments since Excel treats all command line parameters (other than option switches) as names of files it should open. You could use VB6 or VBscript to automate Excel and then run the macros with the required data using the Application.Run syntax Sub Main Dim objExcel As Object Set objExcel = CreateObject( "Excel.Application") objExcel.application.workbooks.open "c:\YourDirectory\YourWorkBook.XLS" ' run macro from workbook objExcel.application.Run ("YourWorkbook.XLS!.Yourmodule.YourMacro" ,YourArg1, YourArg2) Set objExcel = Nothing 'clear object from memory End Sub |
Command Line Arguments
You can use API function GetCommandLine. Here is an example form archive:
http://www.google.pl/groups?hl=pl&lr...adoo.fr&rnum=6 -- Pozdrowienia |
Command Line Arguments
Don't know who your target audience is, but I believe Laurent later reported
that this method does not work in NT and its offspring. -- Regards, Tom Ogilvy "pxd74" wrote in message ... You can use API function GetCommandLine. Here is an example form archive: http://www.google.pl/groups?hl=pl&lr...adoo.fr&rnum=6 -- Pozdrowienia |
All times are GMT +1. The time now is 10:59 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com