|
|
|
date: Fri, 28 Mar 2008 06:33:00 -0700,
group: microsoft.public.word.vba.beginners
back
Re: Document Refresh Macro
Sub UpdateAllFields()
Dim oStory As Range
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
Set oStory = Nothing
End Sub
should update all the fields in your document, including the tables. It
sometimes has problems with fields in header/footer, but we can address that
if it is a problem with your document.
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
DeanH wrote:
> Thanks for the response.
> Tables as in a Table of Contents, and I also have two other "TOCs",
> one for List of Tables and a List of Figures, these are TOCs created
> from the captions.
> These three require the "Update Table of Contents" dialog to go to
> "Update Entire Table" three times (if the document have three such
> tables in it that is, as sometimes I only have a normal TOC).
> But the Macro I am wanting should also refresh any and all other
> fields in the document, ie the captions themselves and
> cross-referencing.
> You have totally lost me with the "story ranges" mentioned.
> Hope this helps.
> DeanH
>
>
> "Graham Mayor" wrote:
>
>> Tables? The macro used as an example at
>> http://www.gmayor.com/installing_macro.htm will update all the
>> fields. If you need to update more thoroughly then you would have to
>> update all the story ranges separately. You can't do this from the
>> macro recorder.
>>
>> --
>> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>> Graham Mayor - Word MVP
>>
>> My web site www.gmayor.com
>> Word MVP web site http://word.mvps.org
>> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>>
>>
>>
>> DeanH wrote:
>>> I would like a macro that did the following:
>>> Select whole document.
>>> F9
>>> Update Entire Table - possibliy three times.
>>> then Repeat once.
>>>
>>> How do you get the Update Entire table to work for different
>>> documents that sometimes have one Table and sometimes three Tables?
>>> Also how to repeat process only once?
>>>
>>> I am a very basic with macros, mainly using Record, but the recorder
>>> does not pick up the Entire Table part of the actions (only
>>> recording Selection.Fields.Update which does not do what is
>>> required) and does not record the possible 3x.
>>>
>>> Also how do you repeat process once?
>>>
>>> Many thanks in advance.
>>> DeanH
date: Fri, 28 Mar 2008 16:39:47 +0200
author: Graham Mayor
Re: Document Refresh Macro
Many thanks for this, unfortunately it still does not do the major thing I
was looking for, namely Refresh the Entire Tables.
It does update the page numbers but not the Entire Table so new Headings and
Captions are captured.
Also how do you get the macro run itself once more? So when the new Headings
and Captions are captured, their new numbers are reflected in the Tables?
Thanks again.
DeanH
Fields in Header/Footer are not a problem.
"Graham Mayor" wrote:
> Sub UpdateAllFields()
> Dim oStory As Range
> 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
> Set oStory = Nothing
> End Sub
>
> should update all the fields in your document, including the tables. It
> sometimes has problems with fields in header/footer, but we can address that
> if it is a problem with your document.
>
> --
> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
> Graham Mayor - Word MVP
>
> My web site www.gmayor.com
> Word MVP web site http://word.mvps.org
> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>
>
> DeanH wrote:
> > Thanks for the response.
> > Tables as in a Table of Contents, and I also have two other "TOCs",
> > one for List of Tables and a List of Figures, these are TOCs created
> > from the captions.
> > These three require the "Update Table of Contents" dialog to go to
> > "Update Entire Table" three times (if the document have three such
> > tables in it that is, as sometimes I only have a normal TOC).
> > But the Macro I am wanting should also refresh any and all other
> > fields in the document, ie the captions themselves and
> > cross-referencing.
> > You have totally lost me with the "story ranges" mentioned.
> > Hope this helps.
> > DeanH
> >
> >
> > "Graham Mayor" wrote:
> >
> >> Tables? The macro used as an example at
> >> http://www.gmayor.com/installing_macro.htm will update all the
> >> fields. If you need to update more thoroughly then you would have to
> >> update all the story ranges separately. You can't do this from the
> >> macro recorder.
> >>
> >> --
> >> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
> >> Graham Mayor - Word MVP
> >>
> >> My web site www.gmayor.com
> >> Word MVP web site http://word.mvps.org
> >> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
> >>
> >>
> >>
> >> DeanH wrote:
> >>> I would like a macro that did the following:
> >>> Select whole document.
> >>> F9
> >>> Update Entire Table - possibliy three times.
> >>> then Repeat once.
> >>>
> >>> How do you get the Update Entire table to work for different
> >>> documents that sometimes have one Table and sometimes three Tables?
> >>> Also how to repeat process only once?
> >>>
> >>> I am a very basic with macros, mainly using Record, but the recorder
> >>> does not pick up the Entire Table part of the actions (only
> >>> recording Selection.Fields.Update which does not do what is
> >>> required) and does not record the possible 3x.
> >>>
> >>> Also how do you repeat process once?
> >>>
> >>> Many thanks in advance.
> >>> DeanH
>
>
>
date: Fri, 28 Mar 2008 08:18:00 -0700
author: DeanH
Re: Document Refresh Macro
It should update the entire table, however if running it twice achieves
that, you can simply loop the code to run twice eg
Sub UpdateAllFields()
Dim oStory As Range
For i = 1 To 2
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
Next i
Set oStory = Nothing
End Sub
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
DeanH wrote:
> Many thanks for this, unfortunately it still does not do the major
> thing I was looking for, namely Refresh the Entire Tables.
> It does update the page numbers but not the Entire Table so new
> Headings and Captions are captured.
> Also how do you get the macro run itself once more? So when the new
> Headings and Captions are captured, their new numbers are reflected
> in the Tables?
>
> Thanks again.
> DeanH
>
>
> Fields in Header/Footer are not a problem.
>
> "Graham Mayor" wrote:
>
>> Sub UpdateAllFields()
>> Dim oStory As Range
>> 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
>> Set oStory = Nothing
>> End Sub
>>
>> should update all the fields in your document, including the tables.
>> It sometimes has problems with fields in header/footer, but we can
>> address that if it is a problem with your document.
>>
>> --
>> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>> Graham Mayor - Word MVP
>>
>> My web site www.gmayor.com
>> Word MVP web site http://word.mvps.org
>> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>>
>>
>> DeanH wrote:
>>> Thanks for the response.
>>> Tables as in a Table of Contents, and I also have two other "TOCs",
>>> one for List of Tables and a List of Figures, these are TOCs created
>>> from the captions.
>>> These three require the "Update Table of Contents" dialog to go to
>>> "Update Entire Table" three times (if the document have three such
>>> tables in it that is, as sometimes I only have a normal TOC).
>>> But the Macro I am wanting should also refresh any and all other
>>> fields in the document, ie the captions themselves and
>>> cross-referencing.
>>> You have totally lost me with the "story ranges" mentioned.
>>> Hope this helps.
>>> DeanH
>>>
>>>
>>> "Graham Mayor" wrote:
>>>
>>>> Tables? The macro used as an example at
>>>> http://www.gmayor.com/installing_macro.htm will update all the
>>>> fields. If you need to update more thoroughly then you would have
>>>> to update all the story ranges separately. You can't do this from
>>>> the macro recorder.
>>>>
>>>> --
>>>> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>>>> Graham Mayor - Word MVP
>>>>
>>>> My web site www.gmayor.com
>>>> Word MVP web site http://word.mvps.org
>>>> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>>>>
>>>>
>>>>
>>>> DeanH wrote:
>>>>> I would like a macro that did the following:
>>>>> Select whole document.
>>>>> F9
>>>>> Update Entire Table - possibliy three times.
>>>>> then Repeat once.
>>>>>
>>>>> How do you get the Update Entire table to work for different
>>>>> documents that sometimes have one Table and sometimes three
>>>>> Tables? Also how to repeat process only once?
>>>>>
>>>>> I am a very basic with macros, mainly using Record, but the
>>>>> recorder does not pick up the Entire Table part of the actions
>>>>> (only recording Selection.Fields.Update which does not do what is
>>>>> required) and does not record the possible 3x.
>>>>>
>>>>> Also how do you repeat process once?
>>>>>
>>>>> Many thanks in advance.
>>>>> DeanH
date: Sat, 29 Mar 2008 12:19:28 +0200
author: Graham Mayor
Re: Document Refresh Macro
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
"Graham Mayor" wrote:
> It should update the entire table, however if running it twice achieves
> that, you can simply loop the code to run twice eg
>
> Sub UpdateAllFields()
> Dim oStory As Range
> For i = 1 To 2
> 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
> Next i
> Set oStory = Nothing
> End Sub
>
>
> --
> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
> Graham Mayor - Word MVP
>
> My web site www.gmayor.com
> Word MVP web site http://word.mvps.org
> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>
>
> DeanH wrote:
> > Many thanks for this, unfortunately it still does not do the major
> > thing I was looking for, namely Refresh the Entire Tables.
> > It does update the page numbers but not the Entire Table so new
> > Headings and Captions are captured.
> > Also how do you get the macro run itself once more? So when the new
> > Headings and Captions are captured, their new numbers are reflected
> > in the Tables?
> >
> > Thanks again.
> > DeanH
> >
> >
> > Fields in Header/Footer are not a problem.
> >
> > "Graham Mayor" wrote:
> >
> >> Sub UpdateAllFields()
> >> Dim oStory As Range
> >> 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
> >> Set oStory = Nothing
> >> End Sub
> >>
> >> should update all the fields in your document, including the tables.
> >> It sometimes has problems with fields in header/footer, but we can
> >> address that if it is a problem with your document.
> >>
> >> --
> >> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
> >> Graham Mayor - Word MVP
> >>
> >> My web site www.gmayor.com
> >> Word MVP web site http://word.mvps.org
> >> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
> >>
> >>
> >> DeanH wrote:
> >>> Thanks for the response.
> >>> Tables as in a Table of Contents, and I also have two other "TOCs",
> >>> one for List of Tables and a List of Figures, these are TOCs created
> >>> from the captions.
> >>> These three require the "Update Table of Contents" dialog to go to
> >>> "Update Entire Table" three times (if the document have three such
> >>> tables in it that is, as sometimes I only have a normal TOC).
> >>> But the Macro I am wanting should also refresh any and all other
> >>> fields in the document, ie the captions themselves and
> >>> cross-referencing.
> >>> You have totally lost me with the "story ranges" mentioned.
> >>> Hope this helps.
> >>> DeanH
> >>>
> >>>
> >>> "Graham Mayor" wrote:
> >>>
> >>>> Tables? The macro used as an example at
> >>>> http://www.gmayor.com/installing_macro.htm will update all the
> >>>> fields. If you need to update more thoroughly then you would have
> >>>> to update all the story ranges separately. You can't do this from
> >>>> the macro recorder.
> >>>>
> >>>> --
> >>>> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
> >>>> Graham Mayor - Word MVP
> >>>>
> >>>> My web site www.gmayor.com
> >>>> Word MVP web site http://word.mvps.org
> >>>> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
> >>>>
> >>>>
> >>>>
> >>>> DeanH wrote:
> >>>>> I would like a macro that did the following:
> >>>>> Select whole document.
> >>>>> F9
> >>>>> Update Entire Table - possibliy three times.
> >>>>> then Repeat once.
> >>>>>
> >>>>> How do you get the Update Entire table to work for different
> >>>>> documents that sometimes have one Table and sometimes three
> >>>>> Tables? Also how to repeat process only once?
> >>>>>
> >>>>> I am a very basic with macros, mainly using Record, but the
> >>>>> recorder does not pick up the Entire Table part of the actions
> >>>>> (only recording Selection.Fields.Update which does not do what is
> >>>>> required) and does not record the possible 3x.
> >>>>>
> >>>>> Also how do you repeat process once?
> >>>>>
> >>>>> Many thanks in advance.
> >>>>> DeanH
>
>
>
date: Sun, 30 Mar 2008 23:13:00 -0700
author: DeanH
Re: Document Refresh Macro
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.
"DeanH" wrote:
> 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
>
> "Graham Mayor" wrote:
>
> > It should update the entire table, however if running it twice achieves
> > that, you can simply loop the code to run twice eg
> >
> > Sub UpdateAllFields()
> > Dim oStory As Range
> > For i = 1 To 2
> > 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
> > Next i
> > Set oStory = Nothing
> > End Sub
> >
> >
> > --
> > <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
> > Graham Mayor - Word MVP
> >
> > My web site www.gmayor.com
> > Word MVP web site http://word.mvps.org
> > <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
> >
> >
> > DeanH wrote:
> > > Many thanks for this, unfortunately it still does not do the major
> > > thing I was looking for, namely Refresh the Entire Tables.
> > > It does update the page numbers but not the Entire Table so new
> > > Headings and Captions are captured.
> > > Also how do you get the macro run itself once more? So when the new
> > > Headings and Captions are captured, their new numbers are reflected
> > > in the Tables?
> > >
> > > Thanks again.
> > > DeanH
> > >
> > >
> > > Fields in Header/Footer are not a problem.
> > >
> > > "Graham Mayor" wrote:
> > >
> > >> Sub UpdateAllFields()
> > >> Dim oStory As Range
> > >> 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
> > >> Set oStory = Nothing
> > >> End Sub
> > >>
> > >> should update all the fields in your document, including the tables.
> > >> It sometimes has problems with fields in header/footer, but we can
> > >> address that if it is a problem with your document.
> > >>
> > >> --
> > >> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
> > >> Graham Mayor - Word MVP
> > >>
> > >> My web site www.gmayor.com
> > >> Word MVP web site http://word.mvps.org
> > >> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
> > >>
> > >>
> > >> DeanH wrote:
> > >>> Thanks for the response.
> > >>> Tables as in a Table of Contents, and I also have two other "TOCs",
> > >>> one for List of Tables and a List of Figures, these are TOCs created
> > >>> from the captions.
> > >>> These three require the "Update Table of Contents" dialog to go to
> > >>> "Update Entire Table" three times (if the document have three such
> > >>> tables in it that is, as sometimes I only have a normal TOC).
> > >>> But the Macro I am wanting should also refresh any and all other
> > >>> fields in the document, ie the captions themselves and
> > >>> cross-referencing.
> > >>> You have totally lost me with the "story ranges" mentioned.
> > >>> Hope this helps.
> > >>> DeanH
> > >>>
> > >>>
> > >>> "Graham Mayor" wrote:
> > >>>
> > >>>> Tables? The macro used as an example at
> > >>>> http://www.gmayor.com/installing_macro.htm will update all the
> > >>>> fields. If you need to update more thoroughly then you would have
> > >>>> to update all the story ranges separately. You can't do this from
> > >>>> the macro recorder.
> > >>>>
> > >>>> --
> > >>>> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
> > >>>> Graham Mayor - Word MVP
> > >>>>
> > >>>> My web site www.gmayor.com
> > >>>> Word MVP web site http://word.mvps.org
> > >>>> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
> > >>>>
> > >>>>
> > >>>>
> > >>>> DeanH wrote:
> > >>>>> I would like a macro that did the following:
> > >>>>> Select whole document.
> > >>>>> F9
> > >>>>> Update Entire Table - possibliy three times.
> > >>>>> then Repeat once.
> > >>>>>
> > >>>>> How do you get the Update Entire table to work for different
> > >>>>> documents that sometimes have one Table and sometimes three
> > >>>>> Tables? Also how to repeat process only once?
> > >>>>>
> > >>>>> I am a very basic with macros, mainly using Record, but the
> > >>>>> recorder does not pick up the Entire Table part of the actions
> > >>>>> (only recording Selection.Fields.Update which does not do what is
> > >>>>> required) and does not record the possible 3x.
> > >>>>>
> > >>>>> Also how do you repeat process once?
> > >>>>>
> > >>>>> Many thanks in advance.
> > >>>>> DeanH
> >
> >
> >
date: Sun, 30 Mar 2008 23:23:00 -0700
author: DeanH
Re: Document Refresh Macro
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
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
DeanH wrote:
> 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.
>
> "DeanH" wrote:
>
>> 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
>>
>> "Graham Mayor" wrote:
>>
>>> It should update the entire table, however if running it twice
>>> achieves that, you can simply loop the code to run twice eg
>>>
>>> Sub UpdateAllFields()
>>> Dim oStory As Range
>>> For i = 1 To 2
>>> 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
>>> Next i
>>> Set oStory = Nothing
>>> End Sub
>>>
>>>
>>> --
>>> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>>> Graham Mayor - Word MVP
>>>
>>> My web site www.gmayor.com
>>> Word MVP web site http://word.mvps.org
>>> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>>>
>>>
>>> DeanH wrote:
>>>> Many thanks for this, unfortunately it still does not do the major
>>>> thing I was looking for, namely Refresh the Entire Tables.
>>>> It does update the page numbers but not the Entire Table so new
>>>> Headings and Captions are captured.
>>>> Also how do you get the macro run itself once more? So when the new
>>>> Headings and Captions are captured, their new numbers are reflected
>>>> in the Tables?
>>>>
>>>> Thanks again.
>>>> DeanH
>>>>
>>>>
>>>> Fields in Header/Footer are not a problem.
>>>>
>>>> "Graham Mayor" wrote:
>>>>
>>>>> Sub UpdateAllFields()
>>>>> Dim oStory As Range
>>>>> 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
>>>>> Set oStory = Nothing
>>>>> End Sub
>>>>>
>>>>> should update all the fields in your document, including the
>>>>> tables. It sometimes has problems with fields in header/footer,
>>>>> but we can address that if it is a problem with your document.
>>>>>
>>>>> --
>>>>> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>>>>> Graham Mayor - Word MVP
>>>>>
>>>>> My web site www.gmayor.com
>>>>> Word MVP web site http://word.mvps.org
>>>>> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>>>>>
>>>>>
>>>>> DeanH wrote:
>>>>>> Thanks for the response.
>>>>>> Tables as in a Table of Contents, and I also have two other
>>>>>> "TOCs", one for List of Tables and a List of Figures, these are
>>>>>> TOCs created from the captions.
>>>>>> These three require the "Update Table of Contents" dialog to go
>>>>>> to "Update Entire Table" three times (if the document have three
>>>>>> such tables in it that is, as sometimes I only have a normal
>>>>>> TOC).
>>>>>> But the Macro I am wanting should also refresh any and all other
>>>>>> fields in the document, ie the captions themselves and
>>>>>> cross-referencing.
>>>>>> You have totally lost me with the "story ranges" mentioned.
>>>>>> Hope this helps.
>>>>>> DeanH
>>>>>>
>>>>>>
>>>>>> "Graham Mayor" wrote:
>>>>>>
>>>>>>> Tables? The macro used as an example at
>>>>>>> http://www.gmayor.com/installing_macro.htm will update all the
>>>>>>> fields. If you need to update more thoroughly then you would
>>>>>>> have to update all the story ranges separately. You can't do
>>>>>>> this from the macro recorder.
>>>>>>>
>>>>>>> --
>>>>>>> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>>>>>>> Graham Mayor - Word MVP
>>>>>>>
>>>>>>> My web site www.gmayor.com
>>>>>>> Word MVP web site http://word.mvps.org
>>>>>>> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> DeanH wrote:
>>>>>>>> I would like a macro that did the following:
>>>>>>>> Select whole document.
>>>>>>>> F9
>>>>>>>> Update Entire Table - possibliy three times.
>>>>>>>> then Repeat once.
>>>>>>>>
>>>>>>>> How do you get the Update Entire table to work for different
>>>>>>>> documents that sometimes have one Table and sometimes three
>>>>>>>> Tables? Also how to repeat process only once?
>>>>>>>>
>>>>>>>> I am a very basic with macros, mainly using Record, but the
>>>>>>>> recorder does not pick up the Entire Table part of the actions
>>>>>>>> (only recording Selection.Fields.Update which does not do what
>>>>>>>> is required) and does not record the possible 3x.
>>>>>>>>
>>>>>>>> Also how do you repeat process once?
>>>>>>>>
>>>>>>>> Many thanks in advance.
>>>>>>>> DeanH
date: Mon, 31 Mar 2008 09:56:22 +0300
author: Graham Mayor
|
|