How to pass a parameter to a startup macro

C

Crisp

I have been trying to pass a parameter to a word macro upon startup, launched
from a VBS script. The VBS script t allows you to drag and drop a file to
it. I wanted it to launch word, which would open the file it was dropped,
and then run the "testLaunch" macro upon startup with the testMsg parameter.
I tried the following, which did not crash, brought up Word with the correct
file, but the macro did not appear to work...

VBS Script:

Set objArgs = WScript.Arguments
doublequote = chr(34)
testMsg = "Hi Cris!"
wordPath = "winword.exe /mtestLaunch(testMsg) " & doublequote
For I = 0 to objArgs.Count - 1
runStr = wordPath & objArgs(I) &doublequote
WScript.Echo runStr
set objShell=CreateObject("Wscript.Shell")
objShell.Run(runStr)
Next

the word macro looks like:
Sub testLaunch(testMsg)
MsgBox testMsg, , "It worked!"
End Sub

Suggestions anyone?
 
W

Word Heretic

G'day "Crisp" <[email protected]>,

The best way is to use an agreed-upon config file. For example, the VB
Script always writes the parms to C:\parms.txt and the template
auto-runs the code required to read this config file.

Steve Hudson - Word Heretic

steve from wordheretic.com (Email replies require payment)
Without prejudice


Crisp reckoned:
 

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