Command line parameters

M

Monika Krug

Hello,

I am going to start a macro from the command line like
this:

"C:\Program Files\Microsoft Office\Office11
\Winword.exe" "C:\My Documents\MyDocument.doc" /mMacroName

Is there a way to specify parameters for a macro on the
command line?
.... /mMacroName(param1, param2) or ... /mMacroName -
param1 -param2 maybe?
If this works, how can one get/use these parameters in the
macro?

(The macro shall connect the document, which is a mail
merge main document, to the specified data source, e.g. an
Excel file, in case this is important.)

Any help would be greatly appreciated,
Monika.
 
M

Monika Krug

I got a hint in the word.mailmerge.fields NG:

The last posting in the thread at
http://groups.google.com/groups?hl=de&lr=&ie=UTF-
8&oe=UTF-8&threadm=uYn%23zte8BHA.976%
40tkmsftngp02&rnum=5&prev=/groups%3Fq%3Dword%2520command%
2520line%2520parameters%2520site%253Amicrosoft.com%26hl%
3Des%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26sa%3DN%26tab%
3Dwg seems to be the only solution:
"Actually, there is one way to "fake it".
You can put the command into a batch file to make it
easier, and before launching Word set an environment
variable, like this:
set myparam=test2
(If doing it in a batch file, make the line
set myparam=%1 and you can issue the parameter as a
command line argument like you are asking).
Then inside Word, using
Environ("myparam")
to retrieve the value of myparam."
(Alex K. Angelopoulos
2002-05-04 microsoft.public.word.vba.addins)

The other suggestion that might work is a VBscript, but I
don't know how to write these.

Monika.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top