Paste chart as a link to Word

Jaymond Flurrie

Well-known Member
Joined
Sep 22, 2008
Messages
921
Office Version
  1. 365
Platform
  1. Windows
I'm having problems pasting a chart to Word:

Code:
With appWD.Selection
        .MoveRight Unit:=wdCharacter, Count:=1
        .TypeText Text:="A part of header"
        .ParagraphFormat.Alignment = wdAlignParagraphLeft
        .TypeText Text:=vbTab & vbTab & "Six digits"

        DocWD.ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
    
        strChartName = "A. My first title"
        shtCharts.Shapes(strChartName).Copy
        .TypeText Text:=vbTab & vbTab & vbTab & vbTab & strChartName & vbCrLf
        .Font.Bold = wdToggle
        .PasteSpecial Link:=False, DataType:=wdPasteMetafilePicture, Placement:=wdInLine, DisplayAsIcon:=False
        .InsertBreak Type:=wdPageBreak
        
        strChartName = "B. My second title"
        shtCharts.Shapes(strChartName).Copy
        .TypeText Text:=vbTab & vbTab & vbTab & vbTab & strChartName & vbCrLf
        .Font.Bold = wdToggle
        .PasteSpecial Link:=True, DataType:=wdPasteEnhancedMetafile, Placement:=wdInLine, DisplayAsIcon:=False
        .InsertBreak Type:=wdPageBreak
End With

First paste works perfectly, but second one gives me Run-time error '5342': The specified datatype is unavailable. What's wrong and how to correct it?

edit. I'm using Office 2010 and that second one works if I change that Link:=True to Link:=False
 
Last edited:

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Just to be clear, the idea is to have it as link, so even if it works with changing that Link:=True to Link:=False, that's not good enough (or if that's the only way it can be done, which I doubt, then I need to program much bigger chunk of code again)
 
Upvote 0

Forum statistics

Threads
1,224,568
Messages
6,179,595
Members
452,927
Latest member
whitfieldcraig

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