q. Using a macro to transfer data from Excel to Word

D

David

Does anyone know a good way to use a macro to paste data copied from an
Excel data table into a Word table. The data will always go to the same
location in Word. For example data copied from the Project Desc field in
Excel will always go to the Project Desc field in Word, data copied from the
Project Location field in Excel will always go to the Project Location field
in Word, etc..

I have advanced knowledge of using macros to move data around in Excel, but
know very little about how to place it into word.

Any help would be greatly appreciated.

David
 
K

K Dales

Is there some reason you can't (or don't want to) link the
Word table to the Excel file? Would make it so simple...

If not, I would think it would work best to write and run
the macro from Word, rather than Excel. Put a reference
to the Excel object library in your Word project and then
use an object variable to hold an Excel session:

Dim XLApp as Excel.Application

Set XLApp = New Excel.Application
XLApp.Workbooks.Open "Path\Filename.xls"

Now you can use all your Excel knowledge to access the
data in your file by referring everything to XLApp - for
example to assign the value of a cell to a variable MyVar
you would say MyVar = XLApp.Sheets(Sheetname).Range
(Celladdress).value.

Then you would need to assign it to the table in Word
using the Word Object model. For that, the Object
Browser, WOrd Help, online help via MSDN and the Word
newsgroup can help you with the details...
 
Top