Paste Excel chart into Word using VBA

MacroAlan

New Member
Joined
Aug 30, 2004
Messages
31
It seemed like it should be so easy. I'm creating a bunch of data from Access and sending to Excel and then creating a bunch of Charts.

Charts look good. As each is created, I want to copy it and paste into a Word document.

Code:
Set WDapp = CreateObject("Word.Application")
    WDapp.Documents.Open RptPath & RptName & WDdate
'Translates to “History Data_20170828.docx”
'------------------ other stuff

    For Z = 1 To ActiveSheet.ChartObjects.Count
        With ActiveSheet.ChartObjects(Z)
            .Left = Range("K" & LftRow).Left
            .Top = Range("K" & LftRow).Top
            .Width = 800
            .Height = 525
            .Copy
        End With
        WDapp.activedocument.PasteSpecial Link:=False, DataType:=wdpastetext, Placement:=wdinline, displayasicon:=False               'This line fails

It's been years since I've done any Word programming in VBA.
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
You need to tell Word where to paste the chart - and use an appropriate paste format (DataType). For example:
WDapp.ActiveDocument.Range.Characters.Last.PasteSpecial Link:=False, DataType:=wdPasteEnhancedMetafile, Placement:=wdInLine, DisplayAsIcon:=False
Using:
.Range.Characters.Last
tells Word to paste the chart at the very end of the document.
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top