Microsoft KB Archive/147195

= How To Run a WordBasic Macro from Within Visual FoxPro =

Article ID: 147195

Article Last Modified on 7/13/2004

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition
 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 6.0 Professional Edition

-



This article was previously published under Q147195



SUMMARY
To run a WordBasic macro from within Visual FoxPro, you can use either OLE automation or DDE. In previous FoxPro versions, you must use DDE.



MORE INFORMATION
For both of the following examples, it is assumed that a WordBasic macro named mymacro has been created. For more information on creating Word macros, please see Microsoft Word's Help file.

Example One (Using DDE)
ichan = DDEInitiate("WinWord","System") *above command assumes that WinWord is running =DDEExecute(ichan,'[ToolsMacro "mymacro" ,.Run]') =DDETerminate(ichan)

Example Two (Using OLE automation)
objWord = CREATEOBJECT("Word.Basic") objWord.ToolsMacro("mymacro",1) RELEASE objWord

Keywords: kbhowto kbinterop kbcode KB147195

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.