Passing variables from Outlook Macro to Word Macro

B

brotherescott

I am trying to send a argument along with a macro call from Outlook
2003 SP1 to Word 2003. The macro call works but I can not get the
argument/variable to work. I followed the syntax in the Word help
file,under Run Method, but I still get a "run-time error 438" message.

'Outlook VBA to start up word and load the correct template
Set WordApp = CreateObject("Word.Application")
WordApp.Visible = True
If WordApp Is Nothing Then
MsgBox "Couldn't Start Word . . . ."
Else
Set oDoc = WordApp.Documents.Add("C:\Documents and
Settings\riddlesm\Application Data\Microsoft\Templates\Pella\Meeting
DateVB3.dot")
End If

If WordApp.ActiveWindow.View.SplitSpecial <> wdPaneNone Then
WordApp.ActiveWindow.Panes(2).Close
End If
If WordApp.ActiveWindow.ActivePane.View.Type = wdNormalView Or
WordApp.ActiveWindow.ActivePane.View.Type = wdOutlineView Then
WordApp.ActiveWindow.ActivePane.View.Type = wdPrintView
End If

WordApp.ActiveWindow.ActivePane.View.SeekView =
wdSeekCurrentPageHeader


A="test" 'variable I am trying to send
WordApp.Run Macroname:="'C:\Documents and
Settings\riddlesm\Application Data\Microsoft\Templates\Pella\Meeting
DateVB3.dot' !macro2", varg1:=A

'The Above Oulook code is the one that generates the error. I
'believe that it is in the correct format but maybe I am
'not seeing something.


Here is my word macro that it calls:
Sub Macro2(A As String)
MsgBox A
End Sub
 

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