So I'm trying to understand what is wrong with my code. All I'm doing is taking some charts in my Excel workbook and exporting them to a Word document but I keep getting an error if I try to paste them a certain way. Here's my code:
Sub ExportingToWord_MultiplePages2()
'Declare Word Variables
Dim WrdApp As Word.Application
Dim WrdDoc As Word.Document
'Declare Excel Variables
Dim ChrtObj As ChartObject
'Create a new instance of Word
Set WrdApp = New Word.Application
WrdApp.Visible = True
'Create a new word document
Set WrdDoc = WrdApp.Documents.Add
'Loop through the charts on the active sheet
For Each ChrtObj In ActiveSheet.ChartObjects
'Copy the chart
ChrtObj.Chart.ChartArea.Copy
**'THIS WON'T RETURN AN ERROR**
With WrdApp.Selection
.PasteAndFormat Type:=wdChartPicture
End With
'**THIS WILL RETURN THE ERROR**
With WrdApp.Selection
.PasteAndFormat Type:=wdChartLinked
End With
'Clear the Clipboard.
Application.CutCopyMode = False
Next ChrtObj
End Sub
This is the weird part because I've provided two different ways to paste, the first one I paste it as a chart picture and that works fine. However, if I try wdChart or wdChartLinked it won't work! I get Error 4605 "Command Not Avaiable".
Any thoughts as to why this would be the case?