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
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