Roderick
02-25-2018, 04:46 PM
I'm using Office 2013 in Windows 10.
I've created a TOC using custom styles: GA Numbered Heading 1 to GA Numbered Heading 6. I don't want to use the inbuilt Heading 1, etc.
This is the field code structure:
{TOC \t "GA Numbered Heading 1,1,GA Numbered Heading 2,2,GA Numbered Heading 3,3,GA Numbered Heading 4,4,
GA Numbered Heading 5,5,GA Numbered Heading 6,6"}
In the body of the document I now create a paragraph of text and then format it with the GA Heading 1 style. There is a macro attached to this process of formatting a paragraph which will update the TOC.
This is the procedure to do it (and big thanks to Graham Mayor):
Sub UpdateTheTocs()
' http://www.gmayor.com/installing_macro.htm
' update TOC fields in a document
Dim oField As Field
For Each oField In ActiveDocument.Fields
If oField.Type = wdFieldTOC Then
oField.Update
End If
Next oField
Set oField = Nothing
End Sub
This works perfectly the first time. However, I now select another paragraph of text and apply the GA Numbered Heading 2 style which then calls the above procedure and all should work OK with the TOC being updated and the new paragraph displayed.
Not so. No matter what I do, the TOC field will just not update. I even try it manually by using Alt+A followed by F9. Still nothing.
Could anyone suggest, please, what is going wrong and a way to put it right?
Thanks
Roderick
I've created a TOC using custom styles: GA Numbered Heading 1 to GA Numbered Heading 6. I don't want to use the inbuilt Heading 1, etc.
This is the field code structure:
{TOC \t "GA Numbered Heading 1,1,GA Numbered Heading 2,2,GA Numbered Heading 3,3,GA Numbered Heading 4,4,
GA Numbered Heading 5,5,GA Numbered Heading 6,6"}
In the body of the document I now create a paragraph of text and then format it with the GA Heading 1 style. There is a macro attached to this process of formatting a paragraph which will update the TOC.
This is the procedure to do it (and big thanks to Graham Mayor):
Sub UpdateTheTocs()
' http://www.gmayor.com/installing_macro.htm
' update TOC fields in a document
Dim oField As Field
For Each oField In ActiveDocument.Fields
If oField.Type = wdFieldTOC Then
oField.Update
End If
Next oField
Set oField = Nothing
End Sub
This works perfectly the first time. However, I now select another paragraph of text and apply the GA Numbered Heading 2 style which then calls the above procedure and all should work OK with the TOC being updated and the new paragraph displayed.
Not so. No matter what I do, the TOC field will just not update. I even try it manually by using Alt+A followed by F9. Still nothing.
Could anyone suggest, please, what is going wrong and a way to put it right?
Thanks
Roderick