Hi there,
I have created a chart in Excel and want this to appear at the Bookmark 'CIPChart' in a premade Word template. This is my code. The Word template opens fine but I can't get the chart to copy and paste into it. Where am I going wrong?
Sub macro()
Dim word As Object, templateFile As Object
On Error Resume Next
Set word = GetObject(, "word.application") 'gives error 429 if Word is not open
If Err = 429 Then
Set word = CreateObject("word.application") 'creates a Word application
Err.Clear
End If
Set templateFile = word.documents.Add(Template:="G:\SavInv\2014 Investment Prop\CIP Healthcheck\Dummy 4.docx")
Sheets("Performance Results").Select
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.ChartArea.Select
ActiveChart.ChartArea.Copy
ActiveWindow.Visible = True
word.ActiveDocument.Bookmarks("CIPChart").Range.PasteSpecial Format:="Picture (Enhanced Metafile)", Link:=False _
, DisplayAsIcon:=False
End Sub
I have created a chart in Excel and want this to appear at the Bookmark 'CIPChart' in a premade Word template. This is my code. The Word template opens fine but I can't get the chart to copy and paste into it. Where am I going wrong?
Sub macro()
Dim word As Object, templateFile As Object
On Error Resume Next
Set word = GetObject(, "word.application") 'gives error 429 if Word is not open
If Err = 429 Then
Set word = CreateObject("word.application") 'creates a Word application
Err.Clear
End If
Set templateFile = word.documents.Add(Template:="G:\SavInv\2014 Investment Prop\CIP Healthcheck\Dummy 4.docx")
Sheets("Performance Results").Select
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.ChartArea.Select
ActiveChart.ChartArea.Copy
ActiveWindow.Visible = True
word.ActiveDocument.Bookmarks("CIPChart").Range.PasteSpecial Format:="Picture (Enhanced Metafile)", Link:=False _
, DisplayAsIcon:=False
End Sub