martin
martin

Reputation: 980

Access word documents header containing a table with vbscript

I need to read the pure text values from cells of a table located in the page header of a word document using vbscript.

All i could achieve until now is to read some kind of text from the header by this:

wscript.echo WordApp.ActiveDocument.Sections(1).Headers(1).Range.FormattedText.Text

But how can i gain access to the table object and read each cell value?

Upvotes: 0

Views: 1073

Answers (1)

Ansgar Wiechers
Ansgar Wiechers

Reputation: 200233

Tables in Word documents can be enumerated via the Tables collection.

For Each tbl In WordApp.ActiveDocument.Sections(1).Headers(1).Range.Tables
  For i = 1 To tbl.Rows.Count
    For j = 1 To tbl.Columns.Count
      WScript.Echo tbl.Cell(i, j).Value
    Next
  Next
Next

Upvotes: 1

Related Questions