0
votes

In a Word document, I have several tables into which I have placed charts within cells. Now I need to access these charts through VBA, to update data values and other properties. The logic driving the updates to the charts is linked to the table the charts are embedded in, so I need to know something about the table context when accessing the charts.

Originally, I had planned to bookmark the tables, and then iterate through the charts associated with each table. However, I now realise that the Word "Table" object doesn't have a "Shapes", or "Inlineshapes", or "Charts" collection.

So my question is: what is the best way to access/reference charts embedded in a table?

1

1 Answers

0
votes

OK, just realised that each cell's "Range" property has an "Inlineshapes" collection where charts embedded will appear.

So I can do this:

With Word.Application

    .Selection.GoTo what:=wdGoToBookmark, Name:="BookmarkName"

    Dim wTable As Word.Table
    Set wTable = .Selection.Tables(1)

    Dim wChart As Word.chart
    Set wChart = wTable.Cell(3, 4).Range.InlineShapes(1).chart
End With

But this means iterating around the cells in the table to get to the charts. However, maybe there's a better way...!