Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2005

Tip: Looking for answers? Try searching our database.

How to pass a parameter to a startup macro

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Crisp - 17 Feb 2005 18:53 GMT
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?
Word Heretic - 21 Feb 2005 07:30 GMT
G'day "Crisp" <Crisp@discussions.microsoft.com>,

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:

>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
[quoted text clipped - 22 lines]
>
>Suggestions anyone?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.