|
| View previous topic :: View next topic |
| Author |
Message |
Tony Broadbent Guest
|
Posted: Thu Dec 20, 2007 3:11 pm Post subject: Passing Parameters between Applications |
|
|
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). |
|
| Back to top |
|
 |
Google Sponsor

|
Posted: Thu Dec 20, 2007 3:11 pm Post subject: Advertisement |
|
|
|
|
| Back to top |
|
 |
Helmut Weber Guest
|
Posted: Thu Dec 20, 2007 4:30 pm Post subject: Re: Passing Parameters between Applications |
|
|
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 |
|
| Back to top |
|
 |
Tony Broadbent Guest
|
Posted: Thu Dec 20, 2007 4:44 pm Post subject: Re: Passing Parameters between Applications |
|
|
"Helmut Weber" wrote:
| Quote: | 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
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 |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|