Article ID: 182585
Article Last Modified on 6/17/2005
Sub InsertXLChart()
Dim xlapp As Excel.Workbook
Documents.Add
' Replace "XLfilename" with a complete path and file name
' for an Excel worksheet that includes a chart.
Set xlapp = GetObject("XLfilename")
' Activate the first chart in the workbook.
xlapp.ActiveSheet.ChartObjects(1).Activate
' Select the chart.
xlapp.ActiveChart.ChartArea.Select
' Copy the chart.
xlapp.ActiveChart.ChartArea.Copy
With Selection
' The wdPasteOLEObject constant will insert the chart as an
' embedded object, and the wdInLine constant will insert the
' chart on the text layer and not the drawing layer.
.PasteSpecial Link:=False, DataType:=wdPasteOLEObject, _
Placement:=wdInLine
End With
' Close the instance of Excel.
Set xlapp = Nothing
End Sub
For additional information, please see the following article in the
Microsoft Knowledge Base:
181058 OFF98: How to Run Sample Code from Knowledge Base Articles
163435 VBA: Programming Resources for Visual Basic for Applications
Additional query words: wordcon vb vba vbe
Keywords: kbhowto kbmacroexample kbprogramming kbdtacode kbcode KB182585