Article ID: 128405
Article Last Modified on 1/19/2007
' The following macro demonstrates how to run the WordBasic macro
' "Macro1" by using DDE
Sub RunWordMacro_DDE()
Dim chan
' Initiate a channel with Microsoft Word.
chan = DDEInitiate("Winword", "System")
' Execute a command on the channel to run the Wordbasic macro.
DDEExecute chan, "[Toolsmacro.name=""Macro1"",.Run]"
' Terminate the channel.
DDETerminate chan
End Sub
' The following macro demonstrates how to run the WordBasic macro
' "Macro1" by using OLE Automation
Sub RunWordMacro_OLE()
Dim WordObj As Object
' Create the WordBasic object.
Set WordObj = CreateObject("Word.Basic")
'
' In Microsoft Excel 97, the line of code to use is
'
' Set WordObj = CreateObject("Word.Basic.8")
' Run the WordBasic macro "Macro1".
With WordObj
.ToolsMacro Name:="Macro1", Run:=True
End With
' Set the WordBasic object to nothing to end OLE Automation.
Set WordObj = Nothing
End Sub
For additional information, please see the following article in the
Microsoft Knowledge Base:
120979 How to Use Named WordBasic Arguments in OLE Automation
Additional query words: 97 WORD7 WORD97 XL
Keywords: KB128405