passing parameters from command line

  • Thread starter Thread starter Albrecht Hesmert
  • Start date Start date
A

Albrecht Hesmert

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
 
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
 
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
 
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
 
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
 
Back
Top