![]() |
|
#1
|
|||
|
|||
![]()
Hi:
I have a document template (.docx), which is used by different user groups in different parts of the world. Since, the different regions have different separators defined by OS settings, the TOC doesn't get updated automatically and throws an error. To mitigate this problem, I check the separator using this code , which I found online: Code:
{ IF { =product(2;3) } = 6 "{ SET list ";" }" "" }{ IF { =product(2,3) } = 6 "{ SET list "," }" "" } { TOC \t "style1{ list }1{ list }style2{ list }2" \h \z \u } Is there a way that the first part of code is executed automatically, whenever someone tries to update the TOC. Please note that, this code needs to be invisible so nobody can change it and VBA is not an option. Any useful suggestion will be highly appreciated. Please let me know if something is unclear. Thanks. Best Regards, Ajay |
#2
|
|||
|
|||
![]()
Your solution is innovative and shows a lot of understanding of Word.
I would suggest using a bookmark name other than "list." That term may cause you problems in documentation. Your code is fields. Fields are, by their very nature as a part of a document body, fragile. Bookmarks are even more fragile. Bookmarks are very easily deleted or destroyed even when the contents are displayed. Can you put the field including the TOC in a Section of the document which is protected from editing? I believe this would mean that the only updating would be automatic upon printing. I have not tried this, just making a suggestion. Otherwise, can your train your people to select an entire area when updating the TOC so it will include your preliminary fields? Perhaps some innocuous symbols that mark the beginning and end of the area to be updated? |
#3
|
|||
|
|||
![]()
Hi Charles:
Thanks a lot for your reply and a description about lists and bookmarks. Unfortunately, the organization I work for is too big and it won't be possible to train each and everyone. However, since, it looks like we don't have any other option, we will just put a comment in the document (it's a pity, I wish Microsoft could have been more innovative), so that the user know that they have to update the code before they update the TOC. I hope it works. Meanwhile, if you find something else, please let me know. Thanks. |
#4
|
||||
|
||||
![]()
An alternative, which you may already have considered, is to make use of Word's built-in headings (these can be customized to suit your formatting needs). The heading styles have different names across the world, but they all respond to the \o switch: For example, { TOC \o "1-4" \h } bases the TOC on styles using Heading 1 through Heading 4.
__________________
Stefan Blom Microsoft Word MVP Microsoft 365 apps for business Windows 11 Professional |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
terry795 | Word | 16 | 01-07-2016 04:33 PM |
![]() |
ChrisC | Mail Merge | 1 | 06-18-2012 07:11 PM |
![]() |
Jamal NUMAN | Word | 2 | 07-03-2011 03:11 AM |
Add automatic separator in caption "Figure 1: __" | poobear | Word | 1 | 05-12-2011 04:05 PM |
"Outlook could not create the work file." error. All settings look good, any ideas? | Booshanky | Outlook | 0 | 08-31-2010 09:36 AM |