Excel: How to Run a Word for Windows Macro from Excel

ID: Q94364


The information in this article applies to:
  • Microsoft Excel for Windows, versions 3.x, 4.x, 5.0, 5.0c
  • Microsoft Excel for Windows 95, version 7.0


SUMMARY

In Microsoft Excel for Windows, you can use the EXECUTE() function to run version 2.0 Microsoft Word for Windows macros in a dynamic data exchange (DDE) macro.


MORE INFORMATION

Microsoft provides macro examples for illustration only, without warranty either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. This macro is provided 'as is' and Microsoft does not guarantee that the following code can be used in all situations. Microsoft does not support modifications of the code to suit customer requirements.

The following is a sample macro that runs a Microsoft Word for Windows macro called TEST from Microsoft Excel. In order to run this macro, use the WordBasic command ToolsMacro in the EXECUTE() function.


   A1:   =INITIATE("winword","system")
   A2:   =EXECUTE(A1,"[ToolsMacro.Name=""TEST"",.Run]")
   A3:   =TERMINATE(A1)
   A4:   =RETURN() 


For more information about the ToolsMacro function choose Help Index from the Help menu in Word for Windows, search on WordBasic, select WordBasic Programming Language, choose the Go To button, and select ToolsMacro from the list of WordBasic functions and statements.

Explanation of Macro

A1: Initiates the channel to Word for Windows.

A2: Executes the ToolsMacro WordBasic command to run the macro called "TEST".

NOTE: The two quotation marks on each side of the macro name are required to produce the one set of quotation marks needed by Word.

A3: Terminates the DDE channel to Word for Windows.

A4: Ends the macro.


REFERENCES

"Function Reference," version 4.0, pages 139-140
"Function Reference," version 3.0, pages 71-72

Additional query words: 3.0 3.00 4.0 4.00 4.0a 4.00a 5.0 word basic run

Keywords :
Version : 3.00 4.00 4.00a 5.00 5.00c 7.00
Platform : WINDOWS
Issue type :


Last Reviewed: March 30, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.