ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   q. Using a macro to transfer data from Excel to Word (https://www.excelbanter.com/excel-programming/307585-q-using-macro-transfer-data-excel-word.html)

David

q. Using a macro to transfer data from Excel to Word
 
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




Township of East Hanover

q. Using a macro to transfer data from Excel to Word
 
Try this:

http://www.erlandsendata.no/english/...olecontrolword


"David" wrote in message
...
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 Dales

q. Using a macro to transfer data from Excel to Word
 
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...


-----Original Message-----
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



.



All times are GMT +1. The time now is 05:23 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com