TOC with no entries

P

pum

Dear word numberers,

I have a document with three tables of contents: one for a general
table of contents and the other two for figures and tables, resp. I
would like to modify the TOC field for the last two tables in order to
show a message like "No figures in this document" if the TOC has no
entries. The field code for the table of contents is:

{ TOC \h \z \t "Figure caption" \c }

Thanks in advance,

Unai
 
S

Suzanne S. Barnhill

When there are no figures, the TOC field will display "Error! No table of
figures entries found." So it *should* be possible to accomplish what you
want this way:

{ IF { TOC \h \z \t "Figure caption" \c } = "Error! No table of figures
entries found." "No figures in this document" "{ TOC \h \z \t "Figure
caption" \c }" }

Unfortunately, I tried this, and it does not work. Perhaps someone else can
come up with a better solution.


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org
 
S

Stefan Blom

I believe the problem is that the exact error message may be different with different versions of Word. In Word 2007, the error message does not necessarily include the word "error." Try "No table of figures entries found." only.

You could also generate the error message in a global variable using something like this:

{ SET errmessage { TOC \c "nonexistingfigurelabel" } }

and then use { REF errmessage } in the IF construct.

Stefan Blom
Microsoft Word MVP



"Suzanne S. Barnhill" wrote in message
When there are no figures, the TOC field will display "Error! No table of
figures entries found." So it *should* be possible to accomplish what you
want this way:

{ IF { TOC \h \z \t "Figure caption" \c } = "Error! No table of figures
entries found." "No figures in this document" "{ TOC \h \z \t "Figure
caption" \c }" }

Unfortunately, I tried this, and it does not work. Perhaps someone else can
come up with a better solution.


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org
 
S

Suzanne S. Barnhill

I was trying it in Word 2003, where the error message is exactly as I quoted
it, but I think the problem is that the IF field is basically
self-referential. I did think about bookmarking the TOC and REFing it, but I
couldn't see how that could help. That is, if the only occurrence of the TOC
is inside the IF field, then I don't see how it can work, but if there is an
instance of the TOC field outside the IF field, then you're going to get the
standard error message in addition to the custom one.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org
 
S

Stefan Blom

The advantage of SET fields is that you can store the actual error message displayed and, for example, display it using a REF field.

I'll have to continue my experiments with this tomorrow. :)

Stefan Blom
Microsoft Word MVP



"Suzanne S. Barnhill" wrote in message
I was trying it in Word 2003, where the error message is exactly as I quoted
it, but I think the problem is that the IF field is basically
self-referential. I did think about bookmarking the TOC and REFing it, but I
couldn't see how that could help. That is, if the only occurrence of the TOC
is inside the IF field, then I don't see how it can work, but if there is an
instance of the TOC field outside the IF field, then you're going to get the
standard error message in addition to the custom one.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org
 
S

Stefan Blom

Since the TOC field being used references a style, you'd have to check for the presence of that style in the document. For the SET field, use the following field:

{ SET errmessage { TOC \t "nonexistingstylename" \c } }

And then use the IF field I suggested in a previous message.

Stefan Blom
Microsoft Word MVP



"Stefan Blom" wrote in message
The advantage of SET fields is that you can store the actual error message displayed and, for example, display it using a REF field.

I'll have to continue my experiments with this tomorrow. :)

Stefan Blom
Microsoft Word MVP



"Suzanne S. Barnhill" wrote in message
I was trying it in Word 2003, where the error message is exactly as I quoted
it, but I think the problem is that the IF field is basically
self-referential. I did think about bookmarking the TOC and REFing it, but I
couldn't see how that could help. That is, if the only occurrence of the TOC
is inside the IF field, then I don't see how it can work, but if there is an
instance of the TOC field outside the IF field, then you're going to get the
standard error message in addition to the custom one.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org
 
P

pum

Since the TOC field being used references a style, you'd have to check for the presence of that style in the document. For the SET field, use the following field:

{ SET errmessage { TOC \t "nonexistingstylename" \c } }

And then use the IF field I suggested in a previous message.

Stefan Blom
Microsoft Word MVP

"Stefan Blom"  wrote in message
The advantage of SET fields is that you can store the actual error message displayed and, for example, display it using a REF field.

I'll have to continue my experiments with this tomorrow. :)

Stefan Blom
Microsoft Word MVP

"Suzanne S. Barnhill"  wrote in message
I was trying it in Word 2003, where the error message is exactly as I quoted
it, but I think the problem is that the IF field is basically
self-referential. I did think about bookmarking the TOC and REFing it, but I
couldn't see how that could help. That is, if the only occurrence of the TOC
is inside the IF field, then I don't see how it can work, but if there isan
instance of the TOC field outside the IF field, then you're going to get the
standard error message in addition to the custom one.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org















- Mostrar texto de la cita -

Dear Suzanne and Stefan,

Thank you very much for your interest and quick answers. I (almost)
have the desired result. I mean, I have the desired customized message
when there are no entries in my TOC, and a TOC when there are some
entries. But the format of this TOC is not the same I got with the
original field.

The syntaxis I use now is

{ SET errmessage { TOC \h \z \t "My style" \c } }{ IF { REF
errmessage } = "
¡Error! No se encuentran elementos de tabla de ilustraciones." "My
customized text" "{ TOC \h \z \t "My style" \c }"}

(My computer and I speak Spanish, sorry for that)

I have had to include a carriage return in the standard error
message comparison with the REF field (I only discovered that after
some try and error). The " around the action in case the IF condition
is false seem to be optional.

The resulting TOC when there are entries is formatted in blue
underlined font, similar to a standard Hyperlink, instead of the
format of the original TOC in black font with some parts in bold and
so on.

Do you know if there is a way to control the format of this TOC? I
am going to read again the tutorials for TOCs by Suzanne and other
MVPs, but if you could point a particular link for this I would
appreciate it very much.

Thanks again for your help. It is a great luck for regular Word
users that people like you are helping us.
 
S

Suzanne S. Barnhill

This is an unexpected but not entirely surprising result for a linked TOC.
By default, Word suppresses the normal Hyperlink style for hyperlinked TOCs
and cross-references, but it would appear that this field construction is
resulting in the style being applied as usual. Two possible workarounds:

1. Don't hyperlink the TOC (omit the \h switch). Since page numbers will
still by hyperlinked, however, they may be formatted.

2. If you don't have any other hyperlinks in the document that you want
formatted as blue and underlined, modify the Hyperlink (and Followed
Hyperlink) styles to be just Default Paragraph Font instead of Default
Paragraph Font + Underline, Font color: Blue/Violet.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org

Since the TOC field being used references a style, you'd have to check for
the presence of that style in the document. For the SET field, use the
following field:

{ SET errmessage { TOC \t "nonexistingstylename" \c } }

And then use the IF field I suggested in a previous message.

Stefan Blom
Microsoft Word MVP

in
message
The advantage of SET fields is that you can store the actual error message
displayed and, for example, display it using a REF field.

I'll have to continue my experiments with this tomorrow. :)

Stefan Blom
Microsoft Word MVP

in
message
I was trying it in Word 2003, where the error message is exactly as I
quoted
it, but I think the problem is that the IF field is basically
self-referential. I did think about bookmarking the TOC and REFing it, but
I
couldn't see how that could help. That is, if the only occurrence of the
TOC
is inside the IF field, then I don't see how it can work, but if there is
an
instance of the TOC field outside the IF field, then you're going to get
the
standard error message in addition to the custom one.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org















- Mostrar texto de la cita -

Dear Suzanne and Stefan,

Thank you very much for your interest and quick answers. I (almost)
have the desired result. I mean, I have the desired customized message
when there are no entries in my TOC, and a TOC when there are some
entries. But the format of this TOC is not the same I got with the
original field.

The syntaxis I use now is

{ SET errmessage { TOC \h \z \t "My style" \c } }{ IF { REF
errmessage } = "
¡Error! No se encuentran elementos de tabla de ilustraciones." "My
customized text" "{ TOC \h \z \t "My style" \c }"}

(My computer and I speak Spanish, sorry for that)

I have had to include a carriage return in the standard error
message comparison with the REF field (I only discovered that after
some try and error). The " around the action in case the IF condition
is false seem to be optional.

The resulting TOC when there are entries is formatted in blue
underlined font, similar to a standard Hyperlink, instead of the
format of the original TOC in black font with some parts in bold and
so on.

Do you know if there is a way to control the format of this TOC? I
am going to read again the tutorials for TOCs by Suzanne and other
MVPs, but if you could point a particular link for this I would
appreciate it very much.

Thanks again for your help. It is a great luck for regular Word
users that people like you are helping us.
 

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