Refresh of chart after modification through VBA ?

B

Brian Ipsen

Hi

I'm trying to update a chart inside a MS Word 2007 document... My code
looks like this:

Sub FixStgPrimCopyChart(ByVal PrimValue As Variant, ByVal CopyValue As
Variant)
Dim lNumShapes As Long
Dim lShapeCnt As Long
Dim wrdActDoc As Document
Dim oOleFormat As OLEFormat
Dim oWorkbook As Excel.Workbook
Dim oWorksheet As Excel.Worksheet
Dim oIS As InlineShape
Dim oChart As Chart

Set wrdActDoc = ActiveDocument
For lShapeCnt = 1 To 1 'wrdActDoc.InlineShapes.Count
If wrdActDoc.InlineShapes(lShapeCnt).Type = wdInlineShapeChart Then
Set oIS = wrdActDoc.InlineShapes(lShapeCnt)
If oIS.HasChart Then
Set oChart = oIS.Chart
oChart.ChartData.Activate
Set oWorkbook = oChart.ChartData.Workbook
Set oWorksheet = oWorkbook.Worksheets("Sheet1")
oWorksheet.Range("B2") = FormatNumber(PrimValue / 1024,
0, , , 0)
oWorksheet.Range("C2") = FormatNumber(CopyValue / 1024,
0, , , 0)
oWorkbook.Close
oChart.Refresh
End If
End If
Next lShapeCnt
End Sub


My problem is that the data sheet is updated as expected - but the graph
(graphics) in the document is not updated after running my VBA code...

Only when opening the datasheet belonging to the cart - and closing it
again - the graphics is updated (or running the code in single-step
debugging mode).... How do I get the graphics updated through my VBA code ??

Regards
/Brian
 

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