Starting automacros with parameters from cmd-line 
Author Message
 Starting automacros with parameters from cmd-line

I've written an difftool which should be started from the commandline. The macro
should run without any useraction. My Problem now is that i can't start any macro
for example on the event workbook_open(), if the macro contains starting
parameters. Is there any way to autostart Excel with a specified macro and
parameters for that macro.

For example:   ...\msexcel startmacro(param1,param2...)

The other problem is that my macro should return an exitcode back to the cmd-line.
I'm thankful for any help.
Alex



Sat, 04 Oct 2003 19:28:24 GMT  
 Starting automacros with parameters from cmd-line
Quote:
>>parameters. Is there any way to autostart Excel with a specified macro and

parameters for that macro.

For example:   ...\msexcel startmacro(param1,param2...)  >

If  nothing else, couldn't you pass info to/from Excel via file?

That is, startmacro always looks for a particular file; if found, it
opens/reads it for parameters.



Sat, 04 Oct 2003 20:00:00 GMT  
 Starting automacros with parameters from cmd-line
Hi Alex,

I had the same problem, only with Word, some time ago. I decided to have the
AutoExec macro in Word let me select and open an Excel table into which I
then enter my parameters and subsequently have the macro read the contents
of the table. I suppose, you could do the same from Excel.

I could have used a dialog instead, but then I would have to enter the same
text over and over again, when calling the macro.

If someone would write an executable, which transfers command line
parameters to a file and then call Word (or Excel), which the macro could
read, I would be interested in this solution as well.

Lars Hauschultz



Mon, 06 Oct 2003 19:52:02 GMT  
 Starting automacros with parameters from cmd-line
Why send an army to do a baby's job? <g>

Snip this, copy to notepad, save as e.g. AUTOFILE.BAT

:NOTE, only one > in the first line, >>s in subsequent lines
echo %1 > autofile.txt
echo %2 >> autofile.txt
echo %3 >> autofile.txt
  etc
echo %9 >> autofile.txt
:You could add the command line to launch Word here

You type:  AUTOFILE Now Is The Time
AUTOFILE.TXT contains:
Now
Is
The
Time

--
Steve Rindsberg, PowerPoint MVP
Got a PowerPoint wish/suggestion/beef?

Get the PPT FAQs at http://www.rdpslides.com/pptfaq/
RnR PPTools - http://www.rdpslides.com/pptools/
------

Quote:
> Hi Alex,

> I had the same problem, only with Word, some time ago. I decided to have
the
> AutoExec macro in Word let me select and open an Excel table into which I
> then enter my parameters and subsequently have the macro read the contents
> of the table. I suppose, you could do the same from Excel.

> I could have used a dialog instead, but then I would have to enter the
same
> text over and over again, when calling the macro.

> If someone would write an executable, which transfers command line
> parameters to a file and then call Word (or Excel), which the macro could
> read, I would be interested in this solution as well.

> Lars Hauschultz



Mon, 06 Oct 2003 21:22:51 GMT  
 Starting automacros with parameters from cmd-line
Hi Steve,

thanks for your "baby". I changed it to the following:

:Launches Word, calls macro named like first parameter and puts following
parameters as lines in macroprm.txt
:
:NOTE, only one > in the first line, >>s in subsequent lines
echo %2 > macroprm.txt
echo %3 >> macroprm.txt
echo %4 >> macroprm.txt
echo %5 >> macroprm.txt
echo %6 >> macroprm.txt
echo %7 >> macroprm.txt
echo %8 >> macroprm.txt
echo %9 >> macroprm.txt
:Launch Word
echo on
"C:\Program Files\Office2K\Office\WINWORD.EXE" "/m %1"

which works fine, except that empty parameters show up as "ECHO IS OFF" in
the text file.



Tue, 07 Oct 2003 18:50:11 GMT  
 Starting automacros with parameters from cmd-line
Hi, Lars, glad it helped.

Try this instead:

if not %1x==%1 echo %1> something.txt

in each line.

That's two = signs, by the way.

Here, I get a syntax message on the console each time (?) but the result in
the file's right.



Tue, 07 Oct 2003 20:20:01 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Re-using a VB5 program already in memory / cmd line parameter passing

2. Re-using a VB5 program already in memory / cmd line parameter passing

3. Retrieving parameters with cmd.Parameters.Refresh

4. Start Program by pressing cmd button

5. "shell" cmd - app starts minimized

6. Start with starting parameters

7. Acc97: Specifying /CMD parameter when opening database via open dialog

8. PRB: ADO, CMD, SPROC and output parameters...

9. Using CreateProcessA (with CREATE_FORCEDOS) to run PVCS cmd-line app

10. Different results, macro from cmd line vs app

11. Reading cmd line options from VBA

12. Cmd line args?

 

 
Powered by phpBB® Forum Software