MS Office Forum / Word / Numbering / June 2006
TOC not updating in a particular document
|
|
Thread rating:  |
Adrian - 03 May 2006 10:13 GMT Hi,
In a particular document, my TOC is not updating correctly when I select it and choose Update Field. This happens for all styles in the document. It does not happen with other documents. I checked that "automatically update" is enabled for all the TOC styles.
The document has an outline numbering scheme for headings 1 thru 9 and a list numbering scheme. Not sure if this is relevant.
Thanks,
Adrian
Charles Kenyon - 03 May 2006 11:13 GMT First, Automatically Update should be turned off on your styles. This is for developing templates, not documents in use.
Numbering must be applied through styles following the steps at: How to create numbered headings or outline numbering in your Word document http://www.shaunakelly.com/word/numbering/OutlineNumbering.html.
Try displaying the field code for your TOC. (Alt-F9) could you post that code here? Then tell us what is not in your TOC or is displayed improperly? How should the field know which items to include? Finally, which version of Word are you using?
 Signature Charles Kenyon
Word New User FAQ & Web Directory: http://addbalance.com/word
Intermediate User's Guide to Microsoft Word (supplemented version of Microsoft's Legal Users' Guide) http://addbalance.com/usersguide
See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
My criminal defense site: http://addbalance.com --------- --------- --------- --------- --------- --------- This message is posted to a newsgroup. Please post replies and questions to the newsgroup so that others can learn from my ignorance and your wisdom.
> Hi, > [quoted text clipped - 9 lines] > > Adrian Adrian - 03 May 2006 12:15 GMT Hi Charles,
1. I only have "automatically update" on for the TOC1, TOC2 etc styles, not the actual heading styles.
2. I have already applied outline numbering by rigorously following shaun kelly's document :-)
3. Here is the field code for the TOC: TOC \o "2-5" \h \z \t "Heading 1,1,Heading 6,1,Heading 7,2,Heading 8,3,Heading 9,4,PLSIXTitle,1"
I set up the TOC to show headings 1 thru 9, plus the style "PLSIXTitle". Headings 1- 9 are modifications of the default Word h1-h9 headings. H6 to H9 are used for appendixes and I set them as level 1 to 4 in the TOC. I find the TOC field codes a little strange as I would have expected to see something like this: TOC \o "1-5" \h \z \t "Heading 6,1,Heading 7,2,Heading 8,3,Heading 9,4,PLSIXTitle,1" I feel this may be another symptom of an underlying problem rather than the cause, because a) the problem still occurs when replacing the field code with what I thought it should be and b) it happens for all entries in the TOC no matter what style they are.
4. You asked what is not displayed correctly... If I edit any of the headings in my document (or the PLSIXTitle entry) and then select the TOC and click update (or F9) the cursor seems to wobble for about a second as if something is happening, but the entries in the TOC do not change. In fact, I don't even get the dialog box that should ask whether I just wanna update page numbers or the whole shebang.
5. Word 2003
I have come across another report of what seems to be the problem, without a working solution:
http://groups.google.com/group/microsoft.public.word.numbering/browse_thread/thr ead/57f904d3dac4ff20/4a76b85c9d18d225?lnk=st&q=word+toc+update&rnum=5&hl=en#4a76 b85c9d18d225
Thanks for your help,
Adrian
> First, Automatically Update should be turned off on your styles. This is > for developing templates, not documents in use. [quoted text clipped - 20 lines] >> >> Adrian Adrian - 03 May 2006 12:36 GMT One other thing that occurs to me...
In another group, I asked if there was an easy way to update fields in all headers and footers throughout a document and a good soul sent me the following macro code, which I added to my document and ran (to test it...it worked).
I did the macro test this morning before I tested the TOC. Could running the macro have screwed up something in the internal workings of my document that now makes it impossible to update the TOC? Here is the code in case it means anything to anybody:
> Sub myUpdateFields() > Dim pRange As Word.Range
> Dim iLink As Long
> iLink = ActiveDocument.Sections(1).Headers(1).Range.StoryType
> For Each pRange In ActiveDocument.StoryRanges
> Do
> pRange.Fields.Update
> Set pRange = pRange.NextStoryRange
> Loop Until pRange Is Nothing
> Next
> End Sub Thanks,
Adrian
> Hi Charles, > [quoted text clipped - 62 lines] >>> >>> Adrian Charles Kenyon - 03 May 2006 14:47 GMT That you are not being asked tells me that Word thinks there are no content modifications. Try typing something in a new heading and then select your TOC field and press F9. Same thing happen (i.e. no change)?
 Signature Charles Kenyon
Word New User FAQ & Web Directory: http://addbalance.com/word
Intermediate User's Guide to Microsoft Word (supplemented version of Microsoft's Legal Users' Guide) http://addbalance.com/usersguide
See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
My criminal defense site: http://addbalance.com --------- --------- --------- --------- --------- --------- This message is posted to a newsgroup. Please post replies and questions to the newsgroup so that others can learn from my ignorance and your wisdom.
One other thing that occurs to me...
In another group, I asked if there was an easy way to update fields in all headers and footers throughout a document and a good soul sent me the following macro code, which I added to my document and ran (to test it...it worked).
I did the macro test this morning before I tested the TOC. Could running the macro have screwed up something in the internal workings of my document that now makes it impossible to update the TOC? Here is the code in case it means anything to anybody:
> Sub myUpdateFields() > Dim pRange As Word.Range [quoted text clipped - 7 lines] > Next > End Sub Thanks, Adrian
"Adrian" <adystrash@hotmail.com> wrote in message news:OZ866JqbGHA.4672@TK2MSFTNGP04.phx.gbl...
> Hi Charles, > [quoted text clipped - 69 lines] >>> >>> Adrian Adrian - 03 May 2006 14:47 GMT Confirmed. The problem is with the macro. Well, actually the problem seems to be a bug in Word related to macro naming. I renamed the macro from "myUpdateFields()" to "UpdateFields( )", which no doubt clashes with a predefined routine of the same name. When I rename it back, the TOC updates with no problem.
I didn't realize there were restrictions on macro naming. I have just done some testing and seen that if you record ANY macro with the macro recorder and name it "UpdateFields" then when you try to update the TOC field in your doc it will run this macro instead :-)
Cheers,
One other thing that occurs to me...
In another group, I asked if there was an easy way to update fields in all headers and footers throughout a document and a good soul sent me the following macro code, which I added to my document and ran (to test it...it worked).
I did the macro test this morning before I tested the TOC. Could running the macro have screwed up something in the internal workings of my document that now makes it impossible to update the TOC? Here is the code in case it means anything to anybody:
> Sub myUpdateFields() > Dim pRange As Word.Range
> Dim iLink As Long
> iLink = ActiveDocument.Sections(1).Headers(1).Range.StoryType
> For Each pRange In ActiveDocument.StoryRanges
> Do
> pRange.Fields.Update
> Set pRange = pRange.NextStoryRange
> Loop Until pRange Is Nothing
> Next
> End Sub
Thanks,
Adrian
"Adrian" <adystrash@hotmail.com> wrote in message news:OZ866JqbGHA.4672@TK2MSFTNGP04.phx.gbl... > Hi Charles, > > 1. I only have "automatically update" on for the TOC1, TOC2 etc styles, not > the actual heading styles. > > 2. I have already applied outline numbering by rigorously following shaun > kelly's document :-) > > 3. Here is the field code for the TOC: > TOC \o "2-5" \h \z \t "Heading 1,1,Heading 6,1,Heading 7,2,Heading > 8,3,Heading 9,4,PLSIXTitle,1" > > I set up the TOC to show headings 1 thru 9, plus the style "PLSIXTitle". > Headings 1- 9 are modifications of the default Word h1-h9 headings. H6 to H9 > are used for appendixes and I set them as level 1 to 4 in the TOC. > I find the TOC field codes a little strange as I would have expected to see > something like this: > TOC \o "1-5" \h \z \t "Heading 6,1,Heading 7,2,Heading 8,3,Heading > 9,4,PLSIXTitle,1" > I feel this may be another symptom of an underlying problem rather than the > cause, because a) the problem still occurs when replacing the field code > with what I thought it should be and b) it happens for all entries in the > TOC no matter what style they are. > > 4. You asked what is not displayed correctly... > If I edit any of the headings in my document (or the PLSIXTitle entry) and > then select the TOC and click update (or F9) the cursor seems to wobble for > about a second as if something is happening, but the entries in the TOC do > not change. In fact, I don't even get the dialog box that should ask whether > I just wanna update page numbers or the whole shebang. > > 5. Word 2003 > > I have come across another report of what seems to be the problem, without a > working solution: > > http://groups.google.com/group/microsoft.public.word.numbering/browse_thread/thr ead/57f904d3dac4ff20/4a76b85c9d18d225?lnk=st&q=word+toc+update&rnum=5&hl=en#4a76 b85c9d18d225 > > > > Thanks for your help, > > > > Adrian > > > "Charles Kenyon" <wordfaq@nospam.addbalance.com> wrote in message > news:u9ssuopbGHA.3956@TK2MSFTNGP04.phx.gbl... >> First, Automatically Update should be turned off on your styles. This is >> for developing templates, not documents in use. >> >> Numbering must be applied through styles following the steps at: How to >> create numbered headings or outline numbering in your Word document >> http://www.shaunakelly.com/word/numbering/OutlineNumbering.html. >> >> Try displaying the field code for your TOC. (Alt-F9) could you post that >> code here? Then tell us what is not in your TOC or is displayed >> improperly? How should the field know which items to include? Finally, >> which version of Word are you using? >> -- >> Charles Kenyon >> >> Word New User FAQ & Web Directory: http://addbalance.com/word >> >> Intermediate User's Guide to Microsoft Word (supplemented version of >> Microsoft's Legal Users' Guide) http://addbalance.com/usersguide >> >> See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome! >> >> My criminal defense site: http://addbalance.com >> --------- --------- --------- --------- --------- --------- >> This message is posted to a newsgroup. Please post replies >> and questions to the newsgroup so that others can learn >> from my ignorance and your wisdom. >> >> >> "Adrian" <adystrash@hotmail.com> wrote in message >> news:O%231RJGpbGHA.3956@TK2MSFTNGP05.phx.gbl... >>> Hi, >>> >>> In a particular document, my TOC is not updating correctly when I select >>> it and choose Update Field. This happens for all styles in the document. >>> It does not happen with other documents. I checked that "automatically >>> update" is enabled for all the TOC styles. >>> >>> The document has an outline numbering scheme for headings 1 thru 9 and a >>> list numbering scheme. Not sure if this is relevant. >>> >>> Thanks, >>> >>> Adrian >>> >> >> > >
Charles Kenyon - 03 May 2006 15:06 GMT See http://word.mvps.org/FAQs/MacrosVBA/InterceptSavePrint.htm. If you give a macro the same name as a built-in Word command, it runs in place of that command. Apparently the macro you are using will not change the contents of a TOC! Here are some you might want to look at.
Sub TOCFieldUpdateAllStory() ' Written by Charles Kyle Kenyon 15 November 2001 ' repaired by Jezebel ' All Story Field Updater - TOC fields Dim oField As Field Dim oStory As Range ' On Error Resume Next For Each oStory In ActiveDocument.StoryRanges ' This goes into headers and footers as well as the regular document Do For Each oField In oStory.Fields If oField.Type = wdFieldTOC Then oField.Update End If Next oField Set oStory = oStory.NextStoryRange Loop Until oStory Is Nothing Next oStory End Sub
Sub FieldsUpdateAllStory() ' All Story Field Updater ' Written by Charles Kyle Kenyon 9 December 2004 ' repaired with help from Jezebel 10 December 2004, 28 November 2005 ' Note, if used in protected form this will reset ' formfields to their defaults Dim oStory As Range On Error Resume Next For Each oStory In ActiveDocument.StoryRanges Do oStory.Fields.Update Set oStory = oStory.NextStoryRange Loop Until oStory Is Nothing Next End Sub
Finally, you'll see yet another update fields macro at http://www.gmayor.com/installing_macro.htm.
I think all of these work on TOC fields. I don't see a conceptual difference between these and the one you are using except the TOC one is acting on fields one at a time and only updating TOC fields. You may want to give them a try. (If you try one and it does not work, please let me know.)
 Signature Charles Kenyon
Word New User FAQ & Web Directory: http://addbalance.com/word
Intermediate User's Guide to Microsoft Word (supplemented version of Microsoft's Legal Users' Guide) http://addbalance.com/usersguide
See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
My criminal defense site: http://addbalance.com --------- --------- --------- --------- --------- --------- This message is posted to a newsgroup. Please post replies and questions to the newsgroup so that others can learn from my ignorance and your wisdom.
Confirmed. The problem is with the macro. Well, actually the problem seems to be a bug in Word related to macro naming. I renamed the macro from "myUpdateFields()" to "UpdateFields( )", which no doubt clashes with a predefined routine of the same name. When I rename it back, the TOC updates with no problem.
I didn't realize there were restrictions on macro naming. I have just done some testing and seen that if you record ANY macro with the macro recorder and name it "UpdateFields" then when you try to update the TOC field in your doc it will run this macro instead :-)
Cheers,
Adrian "Adrian" <adystrash@hotmail.com> wrote in message news:eCQE4VqbGHA.4716@TK2MSFTNGP03.phx.gbl... One other thing that occurs to me...
In another group, I asked if there was an easy way to update fields in all headers and footers throughout a document and a good soul sent me the following macro code, which I added to my document and ran (to test it...it worked).
I did the macro test this morning before I tested the TOC. Could running the macro have screwed up something in the internal workings of my document that now makes it impossible to update the TOC? Here is the code in case it means anything to anybody:
> Sub myUpdateFields() > Dim pRange As Word.Range [quoted text clipped - 7 lines] > Next > End Sub Thanks, Adrian
"Adrian" <adystrash@hotmail.com> wrote in message news:OZ866JqbGHA.4672@TK2MSFTNGP04.phx.gbl...
> Hi Charles, > [quoted text clipped - 69 lines] >>> >>> Adrian Adrian - 03 May 2006 15:33 GMT Thanks Charles,
I sure am learning a lot about Word today!
So, what I thought was a bug seems to be "by design". In that case, I'll limit my criticism to the suggestion that it would be nice if Word were to warn you when you attempt to assign a built-in command name to a macro.
The macro I was given works fine when appropriately named (it updates fields in the header and footer), but thanks for the links anyway.
But before I go, I have a question related to an earlier comment you made....
By default, when one first creates a TOC the styles (e.g. TOC 1) have "automatically update" enabled. However, for all other default styles (Heading 1 etc) this setting is disabled. So, when I see Word MVP advice to disable this setting for all styles after creating a template I wonder if there is any reason to make an exception for the TOC styles? Probably not, but I'm sure you will know if there is...
Cheers,
Adrian
> See http://word.mvps.org/FAQs/MacrosVBA/InterceptSavePrint.htm. If you > give a macro the same name as a built-in Word command, it runs in place of [quoted text clipped - 167 lines] >>>> >>>> Adrian Charles Kenyon - 03 May 2006 17:30 GMT Actually, TOC styles probably would be an exception. If you change the formatting on one entry of a given level you probably want it to apply to all entries. The problem comes up when people have this routinely checked for their body and heading styles. In a well-written template these styles are interconnected with one another and changing one can cascade through a document.
 Signature Charles Kenyon
Word New User FAQ & Web Directory: http://addbalance.com/word
Intermediate User's Guide to Microsoft Word (supplemented version of Microsoft's Legal Users' Guide) http://addbalance.com/usersguide
See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
My criminal defense site: http://addbalance.com --------- --------- --------- --------- --------- --------- This message is posted to a newsgroup. Please post replies and questions to the newsgroup so that others can learn from my ignorance and your wisdom.
> Thanks Charles, > [quoted text clipped - 196 lines] >>>>> >>>>> Adrian Tarallen - 15 Jun 2006 18:48 GMT Hi Charles - you say 'Automatically Update' should be turned off on styles, but it is displaying on the styles in all TOC styles in my template. What is its function and why should be be turned off? Thanks, Tarallen
> First, Automatically Update should be turned off on your styles. This is for > developing templates, not documents in use. [quoted text clipped - 20 lines] > > > > Adrian Suzanne S. Barnhill - 15 Jun 2006 21:22 GMT I think it serves a useful purpose in TOCs because Word has made it so difficult to access TOC styles for modification. Unfortunately, it seems to affect only paragraph, not font, formatting.
 Signature Suzanne S. Barnhill Microsoft MVP (Word) Words into Type Fairhope, Alabama USA Word MVP FAQ site: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.
> Hi Charles - you say 'Automatically Update' should be turned off on styles, > but it is displaying on the styles in all TOC styles in my template. What is [quoted text clipped - 26 lines] > > > > > > Adrian Charles Kenyon - 16 Jun 2006 01:35 GMT Yes, on TOC styles you would want to leave it on usually.
 Signature Charles Kenyon
Word New User FAQ & Web Directory: http://addbalance.com/word
Intermediate User's Guide to Microsoft Word (supplemented version of Microsoft's Legal Users' Guide) http://addbalance.com/usersguide
See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
My criminal defense site: http://addbalance.com --------- --------- --------- --------- --------- --------- This message is posted to a newsgroup. Please post replies and questions to the newsgroup so that others can learn from my ignorance and your wisdom.
> Hi Charles - you say 'Automatically Update' should be turned off on > styles, [quoted text clipped - 34 lines] >> > >> > Adrian
|
|
|