Article ID: 190240
Article Last Modified on 6/17/2005
Sub EditDocChart()
Dim Mychart As Object
' Activates the first object in the document for editing.
ActiveDocument.InlineShapes(1).OLEFormat.Edit
' Makes Mychart equal to MsGraph.Chart.8 object.
Set Mychart = ActiveDocument.InlineShapes(1).OLEFormat.Object
' Changes the value in the datasheet cell referenced in the range.
Mychart.Application.DataSheet.Range("a1").Value = "75"
Mychart.Application.Update
' Changes the chart type (remove the apostrophe from the beginning of
' the line that corresponds to the type of chart you want to change
' to).
'Mychart.Application.Chart.ChartType = xlBarStacked
'Mychart.Application.Chart.ChartType = xlPie
Mychart.Application.Quit
Set Mychart = Nothing
' Deselects the edited graph by moving insertion point.
Selection.HomeKey Unit:=wdStory, Extend:=wdMove
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
Additional query words: wordcon vba vb word
Keywords: kbhowto kbmacroexample KB190240