How To Run a WordBasic Macro from Within Visual FoxPro

Last reviewed: October 17, 1996
Article ID: Q147195
The information in this article applies to:
  • Microsoft Visual FoxPro for Windows, versions 3.0, 3.0b, 5.0

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


Additional reference words: 5.00 3.00 3.00b VFoxWin
KBCategory: kbinterop kbhowto kbcode
KBSubcategory: FxinteropWinword


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: October 17, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.