How to make table of contents for different regional settings?

C

claesafk

I am trying to design a Word template to be used in the company I work for.
Most of the computers are set up to be used in Sweden. This means, for
example, that the comma is used for decimal separator and the semi-colon is
used as a list separator. Most of our writing is made in English. Some
engineers have set the regional settings to use "." as a decimal separator
and the "," as a list separator. This is a problem when, for example,
creating a Word template with table of contents.

Is there a way to write a macro that reads the list separator from from the
regional settings and creates an appropriate TOC field code?
 
P

Peter Jamieson

Is the problem mainly with the list separator in e.g.

{ TOC \t "style1,1,style2,2" \h \z \u }

? If so, something that may work as long as you know all the possible list
separators that your documents' users /might/ use is to use something like
the following immediately before the TOC field:

{ IF { =product(2;3) } = 6 "{ SET list ";" }" "" }{ IF { =product(2,3) } = 6
"{ SET list "," }" "" }

then use

{ TOC \t "style1{ list }1{ list }style2{ list }2" \h \z \u }

where all the {} have to be the special field code braces you can insert
using ctrl-F9

I wouldn't put this into any mailmerge main documents as it will cause
errors to pop up when you merge.
 
C

claesafk

Peter,
Thank you for the tip! It works. This was exactly what I wanted to do. I am
now trying to figure out were to put the code to make sure that it is
"executed" before the TOC is updated and that it is not removed by the user
(as it is invisible). Is there a way to force "update fields" when
opening/closing/printing the document? Personally, I usually click on the TOC
and press F9 to update the table. If I do that without updating the field you
suggested first, I will get an error.

Best regards,
Claes af Klinteberg
 
P

Peter Jamieson

I am
now trying to figure out were to put the code to make sure that it is
"executed" before the TOC is updated

It's always difficult to /ensure that such stuff is updated but nesting all
the fields inside a { QUOTE } field may slightly reduce the possibility that
someone will update the TOC without the other stuff.

e.g. { QUOTE { IF { =product(2;3) } = 6 "{ SET list ";" }" "" }{ IF {
=product(2,3) } = 6 "{ SET list "," }" "" }{ TOC \t "style1,1,style2,2" \h
\z \u } }
Is there a way to force "update fields" when
opening/closing/printing the document?

Only really by using an Auto macro such as AutoOpen (e.g. if you know the
QUOTE field is the first field,

Sub AutoOpen()
ActiveDocument.Content.Fields(1).Select
Selection.Fields.Update
End Sub

may be enough)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top