Rod said:
Not quite working. Have set the reference OK but get the following error
message on the Set objChart = ...
"Class does not support Automation or does not support expected interface."
I am working in Access and manipulating a Word document.
Dim objDoc As Word.Document, objChart As Graph.Chart
Set objDoc = objWord.Documents.Open(..........
Set objChart = objDoc.InlineShapes(1).OLEFormat.Object
The last line throws the error.
Sorry, my bad, you need to Activate it first...
Dim objWord As Word.Application
Dim objDoc As Word.Document
Dim objChart As Graph.Chart
Set objWord = New Word.Application
Set objDoc = objWord.Documents.Open("C:\My Documents\TestChart.doc")
With objDoc
.InlineShapes(1).OLEFormat.Activate
Set objChart = .InlineShapes(1).OLEFormat.Object
End With
With objChart
.Application.DataSheet.Range("A1").Value = 50
'etc.
End With
objDoc.Close wdSaveChanges
objWord.Quit
Set objWord = Nothing
Set objDoc = Nothing
Set objChart = Nothing