Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
passing parameters from command line
Hi,
I want to pass parameters to an excel macro when calling it from command line. e.g. something like: excel myexcel.xls filename.txt The excel macro should process the file filename.txt Is this possible? What do I have to do in the macro to access the parameter? Thanks & regards, Albrecht |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
passing parameters from command line
Hi Albrecht,
I want to pass parameters to an excel macro when calling it from command line. Never heard of this. You could use an auto_open makro or workbook_open-event in the xls-file. However, this will also run everytime *you* open the file. My second solution (that I use under other circumstances) is to have a second excel file that has an workbook_open event that will open your file and call a makro there that will do what you want. You could start the second file in your batchfile, command prompt or whatever. (Sounds complicated but with this method I can run 30 reports automatically every day. All these reports have the same macro.) Best regards arno |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
passing parameters from command line
Hi Arno,
thanks for the reply. Still: When I use Auto_Open, how do I get the parameter (e.g. the filename, that changes every day)? Regards, Albrecht arno schrieb: Hi Albrecht, I want to pass parameters to an excel macro when calling it from command line. Never heard of this. You could use an auto_open makro or workbook_open-event in the xls-file. However, this will also run everytime *you* open the file. My second solution (that I use under other circumstances) is to have a second excel file that has an workbook_open event that will open your file and call a makro there that will do what you want. You could start the second file in your batchfile, command prompt or whatever. (Sounds complicated but with this method I can run 30 reports automatically every day. All these reports have the same macro.) Best regards arno |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
passing parameters from command line
Hi Arno,
thanks for the reply. Still: When I use Auto_Open, how do I get the parameter (e.g. the filename, that changes every day)? Regards, Albrecht arno schrieb: Hi Albrecht, I want to pass parameters to an excel macro when calling it from command line. Never heard of this. You could use an auto_open makro or workbook_open-event in the xls-file. However, this will also run everytime *you* open the file. My second solution (that I use under other circumstances) is to have a second excel file that has an workbook_open event that will open your file and call a makro there that will do what you want. You could start the second file in your batchfile, command prompt or whatever. (Sounds complicated but with this method I can run 30 reports automatically every day. All these reports have the same macro.) Best regards arno |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
passing parameters from command line
Hi Albrecht,
Still: When I use Auto_Open, how do I get the parameter (e.g. the filename, that changes every day)? That's a different story. There _must_ be a rule to find out the filename. If you create the filename, then I would use the same name every day. If this is not possible the you have to know what the name is, eg. it has always todays date. Then you can have a macro like this: myFile = "testFile" myExtension = ".txt" myDate = format(today(), "DDMMYYYY") myFiletoOpen = myFile & myDate & myExtension then you can do with myFiletoOpen whatever you like (it will be "testFile11022004.txt" for today). regards arno |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
passing parameters from command line
oops,
sorry, it should be myDate = Format(Date, "DDMMYYYY") arno |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Are there command line parameters for Excel? | Excel Discussion (Misc queries) | |||
Command line parameters to Excel | Excel Programming | |||
Passing parameters | Excel Programming | |||
Passing parameters to UDF | Excel Programming | |||
Command line parameters into a macro | Excel Programming |