Reputation: 11310
I'm using VBA to create a series of charts in Excel and then copying them into a Word file.
Up till now I've been pasting the charts as pictures, so in Excel I used
ActiveChart.CopyPicture
and then in Word, after selecting the target location:Selection.Paste
.
Now I want to change it so the charts will be editable but not linked to the source Excel file.
I copy a chart from Excel using ActiveChart.ChartArea.Copy
and look at the paste-special options in Word, the options "use destination theme/keep source formatting & embed workbook" work fine for me:
the chart is editable (also the data is editable which I don't need but is OK) and there is no link to the original Excel file.
BUT - I can't find how to perform this through VBA code. Trying to record this in a macro only give me Selection.Paste
- which pastes a linked chart.
I also tried a different approach - pasting a linked chart, and then killing the link. once again, deleting the links in the link editor doesn't get recorded in the macro at all.
Please help with coding any of these two options or suggesting a different approach.
Upvotes: 0
Views: 1068
Reputation: 25663
The Range.PasteAndFormat
method should work. This takes a WdRecoveryType
Enum parameter that lets you specify what kind of result you want.
Selection.PasteAndFormat(wdChart) 'Enum value 14 in case of late binding
Upvotes: 1