Linking a Word Table with a Word Chart

M

Marco

Hi have a simple table that I would like to create a VBA command that will
automatically update the Word chart when the data changes.
I am using the following code but keep getting a "complile error: member or
data member not found" when it hits the iEntry1 =
oDoc.Tables(1).Rows(1).Cells(1).Range.Result line.

Any help would be greatly appreciated.

Private Sub CommandButton1_Click()
Dim oMSGraphWrapper As Word.InlineShape
Dim oDoc As Word.Document
Dim oDataSheet As Graph.DataSheet
Dim oMSGraphObject As Object
Dim iEntry1 As Long
Dim iEntry2 As Long
Set oDoc = ActiveDocument
oDoc.Application.ScreenUpdating = False
Set oMSGraphWrapper = oDoc.InlineShapes(1)
iEntry1 = oDoc.Tables(1).Rows(1).Cells(1).Range.Result
iEntry2 = oDoc.Tables(1).Rows(2).Cells(1).Range.Result
oMSGraphWrapper.OLEFormat.Edit
Set oMSGraphObject = oMSGraphWrapper.OLEFormat.Object
Set oDataSheet = oMSGraphObject.Application.DataSheet

With oDataSheet
.Range("a1").Value = iEntry1
.Range("b1").Value = iEntry2
End With

With oMSGraphObject.Application
.Update
.Quit
End With

oDoc.Application.ScreenUpdating = True

Set oDataSheet = Nothing
Set oMSGraphWrapper = Nothing
Set oDoc = Nothing
Set oMSGraphObject = Nothing

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top