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

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
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,224,815
Messages
6,181,136
Members
453,021
Latest member
Justyna P

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