Test whether a table is captioned from VB

M

Marc Hillman

Am developing a VB script in Word 2003 to perform a few quality checks on
documents against a few rules. One of my rules is that "All tables and
figures must have a caption". How can I check this? Is there any association
between table/figure and caption that I can test?

(Delete REMOVE from my e-mail to reply direct)
_______________________________________
Marc Hillman, Melbourne, Australia
web: http://users.bigpond.net.au/mhillman/
 
D

Doug Robbins - Word MVP

You could use something like:

Dim i as Long, j as Long
Dim afield as Field
With ActiveDocument
i = .Tables.Count
j = 0
For each afield in .Fields
If afield .Type = wdFieldSequence Then
If InStr(afield.Code, "Table") > 1 THen
j = j + 1
End If
End If
Next
If i = j Then
MsgBox "There are the same number of Tables as there are Table
Captions."
Else
MsgBox "The number of Tables and the number of Table Captions do not
match."
End If

You would need to check that the default sequence identifier "Table" has
been used.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

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