Word question regarding TOC (newbie question)...

  • Thread starter Herman Geerlings
  • Start date
H

Herman Geerlings

Dear all,

I have a question regarding the use of the field {TOC}.

I have a Word Template with amongs others the following fieldcode
{TOC \t \n \l 2-2}. This fieldcode is triggered via (Lotusscript/VBA)
code but stops at this part of the code:
==========part of code ==================
appWD.Selection.Style=[value]
==========part of code ==================

This works fine under Office '97 English but not in other versions of
Office.
In Dutch I get for instance the message "Microsoft Word: Er bestaat
geen item met de opgegeven naam." meaning "There is no item with the
given name".

Questions:
-Is it possible that other office versions are not compatible with
this part of the code?
-Or am I looking in the wrong direction?

I know that the information provided is brief. But maybe someone can
give me a clue where to look for an answer.

Regards,

Herman Geerlings
 
C

Cindy M -WordMVP-

Hi Herman,

I'm having difficulty understanding why the problem in your VBA code
could possibly have anything to do with the TOC?

What kinds of things could [value] be?

As a general rule
1. You should refer to built-in styles using a wd constant
2. Word checks for styles by the style name, as it appears in the
document, and this comparison is case-sensitive
3. If a document is opened in a different language version, the
built-in style names will change to that local language (why one should
use the wd constants)

So, my best guess to why you'd be getting the error message is that
[value] isn't in the document...
I have a question regarding the use of the field {TOC}.

I have a Word Template with amongs others the following fieldcode
{TOC \t \n \l 2-2}. This fieldcode is triggered via (Lotusscript/VBA)
code but stops at this part of the code:
==========part of code ==================
appWD.Selection.Style=[value]
==========part of code ==================

This works fine under Office '97 English but not in other versions of
Office.
In Dutch I get for instance the message "Microsoft Word: Er bestaat
geen item met de opgegeven naam." meaning "There is no item with the
given name".

Questions:
-Is it possible that other office versions are not compatible with
this part of the code?
-Or am I looking in the wrong direction?

I know that the information provided is brief. But maybe someone can
give me a clue where to look for an answer.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :)
 
H

Herman Geerlings

Hi Cindy,

thank you for your reply.
I will explain in more detail what the situation is.
I am administring and further developing on a Lotus/Domino application
which has amongst others a module which intergrates with Microsoft
word.

This integration module fills in fields in a Word template with data
from Notes fields and also the field {TOC}.

The application was tested and everything worked well (under Word
English).
However under a Dutch version the integration module does not work
well.
I looked in debug mode and the Notes module stopped at

==>appWD.Selection.style=strSpecialFormat<==

and in the started Word document at the field {TOC \t\n \l 2-2}.

So to answer one of your questions, that is why my focus was and is on
this field.

I looked up in the Word help what the switches meant;
\l \n has something to do with the level of the table of contents and
the
\t has something to do with the style.

What I presume is that in different languages, the values of the
switches are different. Maybe you differ in opinion.

What is more strange is that I can work and generate a word report on
my english verion on the same database and the others cannot generate
a word report in their dutch version.

Questions:
-Are you familiair if in different languages the allowable values for
the switches are different?
-What is a wd constant?


Regards,

Herman Geerlings

p.s. The value that is applied to appWD.Selection.style is "TOC 2", a
string.
p.p.s. I am very open for out of the box thinking. So any suggestion
for this problem, even if you think it is a wild guess is welcome.
 
C

Cindy M -WordMVP-

Hi Herman,
The value that is applied to appWD.Selection.style is "TOC 2", a
string.
Chances are, the problem is that, in the Dutch language version the
style name is not TOC 2, but something else (in German - the second
language I deal with regularly - it's Verzeichnis 2, for example). This
would cause the VBA to stop in its tracks, with the error message you
quoted :)

As I mentioned in my first reply, Word converts the names of the styles
built into it according to the user's language interface.

For this reason, Microsoft provides the wdStyle constants (long data
types) in VBA. If you would pass [value] as a Variant, then you could
use wdStyleTOC2 instead of "TOC 2" and every language version will
recognize it.
I am administring and further developing on a Lotus/Domino application
which has amongst others a module which intergrates with Microsoft
word.

This integration module fills in fields in a Word template with data
from Notes fields and also the field {TOC}.

The application was tested and everything worked well (under Word
English).
However under a Dutch version the integration module does not work
well.
I looked in debug mode and the Notes module stopped at

==>appWD.Selection.style=strSpecialFormat<==

and in the started Word document at the field {TOC \t\n \l 2-2}.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :)
 
H

Herman Geerlings

Hi Cindy,

it worked. I just changed TOC to Inhopg (Dutch) in certain values and
the Word Report was generated.
Now to solve it for our Spanish clients.

In the long run, the code will be made language independent.

Regards,

Herman Geerlings
 

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