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 / December 2007

Tip: Looking for answers? Try searching our database.

Passing Parameters between Applications

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tony Broadbent - 20 Dec 2007 15:11 GMT
I want to have a standard word document, which fills itself with data from
the database, based on an order number.  I then want to call this document
from either Outlook, or Excel, passing in a parameter of the order number.

Currently I have all the code in Outlook to populate the document, but I
really want to move the code into the word template, to avoid having to
replicate the same code in both Outlook and Excel.

How, from Outlook or Excel, do I get this parameter into my Word procedure?
Currently I use something like:
   Set myWord = GetObject(, "Word.Application")
   Set myWordDoc = myWord.Documents.Add(strTemplatePath)

Ideally I want to just call
    myWordDoc.myMacro(myOrderNo)
or something like that, but I suspect it's not so simple.
Any suggestions or guidance much appreciated.

(Apologies if this is a repeat post, I got 'page not found' when I tried to
submit).
Helmut Weber - 20 Dec 2007 16:30 GMT
Hi Tony,

from Excel:

Sub Test()
' Dim oWrd As Word.Application ! early binding
' best practice, so to speak
' but not working here and now
' maybe because of Vista, therefore
Dim oWrd As Object
Set oWrd = GetObject(, "Word.Application")
oWrd.Run "MacroTest", 4 ' a for Word unique macro-name is required!
End Sub

in Word:

Sub MacroTest(lDat As Long)
MsgBox lDat
End Sub

HTH

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
Tony Broadbent - 20 Dec 2007 16:44 GMT
> Hi Tony,
>
[quoted text clipped - 25 lines]
>
> Vista Small Business, Office XP

Thanks Helmut,
That is precisely what I needed.
You wouldn't believe the hours I have struggled trying to do that.
Many many thanks,
Tony
 
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.