Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 184
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 184
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 184
Default passing parameters from command line

oops,

sorry, it should be

myDate = Format(Date, "DDMMYYYY")


arno


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Are there command line parameters for Excel? Michael Excel Discussion (Misc queries) 9 August 5th 07 06:29 PM
Command line parameters to Excel Tom Walker Excel Programming 3 May 23rd 04 06:08 AM
Passing parameters Eleanor[_2_] Excel Programming 0 February 4th 04 05:21 PM
Passing parameters to UDF mbobro[_3_] Excel Programming 5 January 2nd 04 04:25 PM
Command line parameters into a macro Donemowe Excel Programming 3 August 6th 03 09:12 AM


All times are GMT +1. The time now is 02:08 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"