Microsoft KB Archive/57637

{| = Automating a Paste from Excel to Word for Windows =
 * width="100%"|

Last reviewed: November 4, 1994

Article ID: Q57637 The information in this article applies to:
 * Microsoft Excel for Windows, versions 2.1 and 3.0

SUMMARY
The information below describes a macro technique that makes it possible to automatically paste data from Microsoft Excel into Word for Windows.

MORE INFORMATION
The following points are assumed in the sample macro:


 * 1) The area to be copied in Microsoft Excel has been named &quot;area1&quot;.
 * 2) The sheet containing &quot;area1&quot; is the active sheet.
 * 3) The name of the Word for Windows document is contained in cell B1 of the active sheet.
 * 4) There is enough system memory to load Word for Windows, and the paste area is legal within the Word document.

When executed, this macro copies the named range from Microsoft Excel, starts and loads the named document into Word for Windows, performs the paste at the current insertion point, saves the document, and quits Word. The macro code is as follows:

A1: title A2: =SELECT(!area1) A3: =COPY A4: =EXEC(&quot;c:\winword\winword.exe &quot;&!B1,3) A5: =SEND.KEYS(&quot;%ep%fx~&quot;) A6: =RETURN

Cell B1 contains the path and filename of the Word for Windows document (for example, the text &quot;C:\WINWORD\TEST.DOC&quot;). The Microsoft Excel data is pasted into Word for Windows as a table.

For more information, query on the following words:

SEND.KEYS and data and Excel and pasted and table
 * }