
Signature
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Sometimes the caption or bookmark numbering is out of sequence, say after
major shuffling, deletions and additions. Running twice ensures the tables
reflect the new order.
Unfortunately the macro still does not "Update Entire Table", only "Update
Page numbers".
For example if I copy a table caption numbered 10, then paste after - so it
will become Caption number 11. The inital number the copy has is still 10 and
also this new caption is not caputred in the List of Tables. Run the macro,
the caption is now 11, but it is still not captured in the List of Tables.
This is not to say that I copy/paste captions that much (I have a Autotext
for this) but this way clearly shows the Update Entire Table is not occuring.
Sorry to be a pain.
Thanks
DeanH
> It should update the entire table, however if running it twice achieves
> that, you can simply loop the code to run twice eg
[quoted text clipped - 101 lines]
> >>>>> Many thanks in advance.
> >>>>> DeanH
DeanH - 31 Mar 2008 07:23 GMT
Sorry got this the wrong way round. The macro IS updating the number for the
new caption and is capturing the new caption (with new number) on the List of
Tables but is not updating the numbering or name of any caption that was
previously on the List but had been edited or the numbering needs updating.
After running the macro, I do the right click Update Entire Table, all is
well, but that is what I am hoping the macro will do.
> Sometimes the caption or bookmark numbering is out of sequence, say after
> major shuffling, deletions and additions. Running twice ensures the tables
[quoted text clipped - 119 lines]
> > >>>>> Many thanks in advance.
> > >>>>> DeanH
Graham Mayor - 31 Mar 2008 07:56 GMT
When all else fails - a little brute force is needed ;) See how you get on
with the following.
Sub Update()
Dim oField As Field
Dim oStory As Range
Dim oSection As Section
Dim oHeader As HeaderFooter
Dim oFooter As HeaderFooter
Dim oTOC As TableOfContents
Dim oTOF As TableOfFigures
Dim oTOA As TableOfAuthorities
For Each oTOC In ActiveDocument.TablesOfContents
oTOC.Update
Next oTOC
For Each oTOF In ActiveDocument.TablesOfFigures
oTOF.Update
Next oTOF
For Each oTOA In ActiveDocument.TablesOfAuthorities
oTOA.Update
Next oTOA
For Each oStory In ActiveDocument.StoryRanges
For Each oField In oStory.Fields
oField.Update
Next oField
Next oStory
For Each oSection In ActiveDocument.Sections
For Each oHeader In oSection.Headers
If oHeader.Exists Then
For Each oField In oHeader.Range.Fields
oField.Update
Next oField
End If
Next oHeader
For Each oFooter In oSection.Footers
If oFooter.Exists Then
For Each oField In oFooter.Range.Fields
oField.Update
Next oField
End If
Next oFooter
Next oSection
End Sub

Signature
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
> Sorry got this the wrong way round. The macro IS updating the number
> for the new caption and is capturing the new caption (with new
[quoted text clipped - 137 lines]
>>>>>>>> Many thanks in advance.
>>>>>>>> DeanH
DeanH - 31 Mar 2008 09:15 GMT
Many thanks Graham, especially for the perseverance ;-)
This works well. I have trimmed the code down for to fit my needs, Took out
the individual Fields updates, this stops the 250+ actions for a small 50
page document.
Took out the TOA, as I never do these. Took out the Headers and Footers as
these dont need to be updated in this process.
Moved the TOC and TOF to the end of the process so to capture the
renumbering of captions.
Here is what I have now, FYI.
Sub Update1()
Dim oStory As Range
Dim oTOC As TableOfContents
Dim oTOF As TableOfFigures
For Each oStory In ActiveDocument.StoryRanges
oStory.Fields.Update
If oStory.StoryType <> wdMainTextStory Then
While Not (oStory.NextStoryRange Is Nothing)
Set oStory = oStory.NextStoryRange
oStory.Fields.Update
Wend
End If
Next oStory
For Each oTOC In ActiveDocument.TablesOfContents
oTOC.Update
Next oTOC
For Each oTOF In ActiveDocument.TablesOfFigures
oTOF.Update
Next oTOF
End Sub
Thanks again
DeanH
Graham Mayor - 31 Mar 2008 10:53 GMT
I knew we'd get there in the end ;)

Signature
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
> Many thanks Graham, especially for the perseverance ;-)
>
[quoted text clipped - 31 lines]
> Thanks again
> DeanH