View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Jon Peltier Jon Peltier is offline
external usenet poster
 
Posts: 6,582
Default XL Charts to Word

Dangerous Dave -

I am looking to build a macro that will do the following from a single
button click in XL 2003:

1) Open a predefined Word document that I am using as a template;
2) Copy a selected chart to a specified cell within a table in the
document;
2) Repeat for several charts to several different cells in Word.

The Word document is actually an A3 page containing a single 3x3 table. I
want to paste (as pictures) 5 different charts to 5 of these cells. The
charts are already generated within the source workbook on different
sheets.

I can copy a given chart to a single cell (chosen by where the cursor is)
in
an already open document (thanks Jon Peltier), but how do I:


You're welcome!

1) Open the Word document from XL (the name and network path are known and
will always be the same;


You need a Word application object (see
http://peltiertech.com/Excel/XL_PPT.html) and a document:

' Reference existing instance of Word
Set WDApp = GetObject(, "Word.Application")
' Open document
Set WDDoc = WDApp.Documents.Open(strPathAndFileName)


2) Move the cursor between cells in Word so that I can paste the next
chart
in;


See your other post. You don't need to move the cursor, just reference the
range where the item should be pasted.

3) Move between XL and Word files within a macro - I can do this between
different XL workbooks using Windows(nnn).Activate, is there something
similar between applications?


You don't need to move back and forth, nor to activate objects before
working on them, just use code in Excel that references and manipulates the
objects in Word.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______