Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-28-2014, 03:03 PM
Bluebell Bluebell is offline TOC not correct on opening a template Windows 8 TOC not correct on opening a template Office 2010 64bit
Novice
TOC not correct on opening a template
 
Join Date: Jan 2014
Posts: 10
Bluebell is on a distinguished road
Default TOC not correct on opening a template

I have created a template with fillin fields and a table of contents. When I open the template as a document the TOC reverts to show all pages as page 3 (the page number the TOC is on) rather than the actual page numbers themselves. if I update the TOC then it corrects itself, but is there a switch I can set to ensure that it updates automatically on open so all the user has to do is to save the document with a new name and print rather than having to remember to update fields.
Many thanks
Reply With Quote
  #2  
Old 01-28-2014, 03:37 PM
Charles Kenyon Charles Kenyon is offline TOC not correct on opening a template Windows 7 64bit TOC not correct on opening a template Office 2010 32bit
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,464
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

First, the correct way to be using a Template is to create a new document based on it. Many fields update automatically when you do this. What happens when you create a new document by double-clicking on the template's icon?

Templates in Microsoft Word
Reply With Quote
  #3  
Old 01-29-2014, 01:18 AM
Bluebell Bluebell is offline TOC not correct on opening a template Windows 8 TOC not correct on opening a template Office 2010 64bit
Novice
TOC not correct on opening a template
 
Join Date: Jan 2014
Posts: 10
Bluebell is on a distinguished road
Default

I am opening the template as a document which is why it does not have a name only document 1 etc.
The TOC is there, the fillin fields are correctly populated but I need to manually RMB and update fields to get the TOC to populate correcty (or click the update button). users then save and print
Many thanks
Reply With Quote
  #4  
Old 01-29-2014, 08:30 AM
Charles Kenyon Charles Kenyon is offline TOC not correct on opening a template Windows 7 64bit TOC not correct on opening a template Office 2010 32bit
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,464
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

Send me the document at the parsed address below and I'll take a look at it.

wordfaq[at]addbalance[dot]com

I am a trial lawyer and have other priorities, but I will look at it.

The terminology or jargon of Word is that when you open a template, the template itself is on your screen and if type and save it, the template itself is changed. You use the template by creating a new document. This appears to be what you are doing but the terms you use confuse things.
Reply With Quote
  #5  
Old 02-03-2014, 04:21 PM
Charles Kenyon Charles Kenyon is offline TOC not correct on opening a template Windows 7 64bit TOC not correct on opening a template Office 2010 32bit
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,464
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

I've looked at your document. If you can use macros, the following macro in your template should do the trick.

Code:
Sub AutoNew()
' See http://www.gmayor.com/installing_macro.htm
' Written by Charles Kenyon 2014-02-03
'
' update TOC fields in a document
    Dim oField As Field
    For Each oField In ActiveDocument.Fields
        If oField.Type = wdFieldTOC Then oField.Update
    Next oField
    Set oField = Nothing
End Sub

Note, you will have to save this template as a .dotm template.
Reply With Quote
  #6  
Old 02-04-2014, 10:38 AM
Bluebell Bluebell is offline TOC not correct on opening a template Windows 8 TOC not correct on opening a template Office 2010 64bit
Novice
TOC not correct on opening a template
 
Join Date: Jan 2014
Posts: 10
Bluebell is on a distinguished road
Default

Thank you so much, this works perfectly.
Your help is really appreciated.
Reply With Quote
  #7  
Old 02-04-2014, 07:41 PM
macropod's Avatar
macropod macropod is offline TOC not correct on opening a template Windows 7 32bit TOC not correct on opening a template Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,365
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Simpler and more comprehensive:
Code:
Sub AutoNew()
Dim TOC As TableOfContents
For Each TOC In ActiveDocument.TablesOfContents
  TOC.Update
Next
End Sub
Note that the above fully updates the TOC (e.g. for new/edited entries), whereas Charles' version only updates the page #s (though I don't know why anything about a TOC would need updating via an AutoNew macro - AutoOpen I could understand).
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #8  
Old 02-05-2014, 04:43 AM
Charles Kenyon Charles Kenyon is offline TOC not correct on opening a template Windows 7 64bit TOC not correct on opening a template Office 2010 32bit
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,464
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

Paul,

Thanks for the code simplification. I learn something new every day. I just started with code to update all fields in the body of a document and restricted it. Your code is much more elegant.

This template needs it in the AutoNew because for some reason the TOC pages reset to all be "3" in a new document based on the template. There are an (annoying) series of questions (ASK) or (FILL-IN) fields that trigger upon the creation of the new document and it may then be ready to go.

A UserForm would be more user-friendly and flexible but this is what the OP has.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
TOC not correct on opening a template Auto Correct RodneyJ Word 12 11-06-2014 06:17 AM
Error message when opening any template spiff1116 Word 6 11-04-2013 04:44 PM
Which .pst is the correct .pst dbsoccer Outlook 1 04-08-2012 12:12 PM
Word normal template changed??? Auto correct file??? Frankwhoa Word 0 03-10-2010 04:46 PM
Template "File In Use" when opening 2 documents based on the same template wendt Word 5 12-15-2009 12:37 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:17 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft