Custom footnote paragraph style removes manually formatting

A

andreas

Below macro applies a custom paragraph style to all footnotes of a
document. It is running just fine.

In a superlong Document with more than 900 footnotes, a little bug
occurs. Some words (but only some!!) that have been preformatted
manually with italics or underlined LOOSE this manual character
formatting. But this should not be the case because the custom
paragraph style does NOT contain any character formatting properties
(italics, underlined, bold etc.) nor do I use "Range.Font.Reset" in
this macro.

Any hint why this is so? Maybe it is because of the big number of
footnotes?
Help is appreciated. Thank you very much in advance.


Sub FNFormat()
Dim pIndex As Long

If ActiveDocument.Footnotes.Count > 0 Then

For pIndex = 1 To ActiveDocument.Footnotes.Count

ActiveDocument.Footnotes(pIndex).Range.Style = "Custom Footnote
Paragraph Style"
Next

End If

End Sub
 
S

Shauna Kelly

Hi Andreas

Is the following what is happening?

Case 1: Footnote text is "_Merchant of Venice_ (1600)"
In this case, when you apply the paragraph style, "Merchant of Venice" loses
its italics.

Case 2: Footnote text is "The main character in Shakespeare's _Merchant of
Venice_ is Shylock, a money-lender who wants his pound of flesh."
In this case, when you apply the paragraph style, "Merchant of Venice"
retains its italics.

If this is the case, then what is happening is Word's expected behaviour. It
is not a bug.

All paragraph styles contain both paragraph properties (eg space before)
*and* character properties (eg font and font size). A paragraph always has a
paragraph style applied to it and may, in addition, have direct formatting
applied. Direct formatting over-rides the formatting derived from the style.
So in both cases above, "Merchant of Venice" has direct italics formatting
applied.

When Word applies a paragraph style, it looks to see what direct formatting
has been applied. If direct formatting has been applied to more than 50% of
the text in the paragraph, then the paragraph style is applied, and the
direct formatting is lost. If direct formatting has been applied to less
than 50% of the text in the paragraph, then the paragraph style is applied,
and the direct formatting is retained.

This is actually how you expect Word to work. Imagine a paragraph in Normal
style where all the text in the paragraph has been formatted with 20pt blue
underline. Now, you apply, say, Body Text style to the paragraph. You would
expect to lose the blue 20pt underline. On the other hand, if you have a
paragraph like the second footnote above, and you apply a new paragraph
style, you would expect to retain the italics.

There is no way around this in your case, and it's one very good reason to
use Word's built-in styles. In this case, I recommend that you modify the
built-in Footnote Text style to suit your needs and let Word work in its
normal way.

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
 
H

Helmut Weber

Hi Andreas,

Shauna told you. But if there is a lot of
direct formatting and for whatever reason
you don't have the time to set it all up the proper
way, then one might think of using highlighting
to mark pieces of text in italic before you apply your
footnote style, and apply the direct formatting
afterwards again to the highlighted spots,
and remove the highlight.

Which won't work if there are pieces of text
e.g. formatted as italic plus underlined.

One might even think of setting up an array
of ranges for a footnote.
Store the italic ranges there.
Do your formatting, restore the ranges to italic.

Or a multidimensional array,
holding ranges and the formatting.

But then you would be close to re-inventing
the structure of Word-documents.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
A

andreas

Hi Andreas

Is the following what is happening?

Case 1: Footnote text is "_Merchant of Venice_ (1600)"
In this case, when you apply the paragraph style, "Merchant of Venice" loses
its italics.

Case 2: Footnote text is "The main character in Shakespeare's _Merchant of
Venice_ is Shylock, a money-lender who wants his pound of flesh."
In this case, when you apply the paragraph style, "Merchant of Venice"
retains its italics.

If this is the case, then what is happening is Word's expected behaviour. It
is not a bug.

All paragraph styles contain both paragraph properties (eg space before)
*and* character properties (eg font and font size). A paragraph always has a
paragraph style applied to it and may, in addition, have direct formatting
applied. Direct formatting over-rides the formatting derived from the style.
So in both cases above, "Merchant of Venice" has direct italics formatting
applied.

When Word applies a paragraph style, it looks to see what direct formatting
has been applied. If direct formatting has been applied to more than 50% of
the text in the paragraph, then the paragraph style is applied, and the
direct formatting is lost. If direct formatting has been applied to less
than 50% of the text in the paragraph, then the paragraph style is applied,
and the direct formatting is retained.

This is actually how you expect Word to work. Imagine a paragraph in Normal
style where all the text in the paragraph has been formatted with 20pt blue
underline. Now, you apply, say, Body Text style to the paragraph. You would
expect to lose the blue 20pt underline. On the other hand, if you have a
paragraph like the second footnote above, and you apply a new paragraph
style, you would expect to retain the italics.

There is no way around this in your case, and it's one very good reason to
use Word's built-in styles. In this case, I recommend that you modify the
built-in Footnote Text style to suit your needs and let Word work in its
normal way.

Hope this helps.

Shauna Kelly. Microsoft MVP.http://www.shaunakelly.com/word














- Zitierten Text anzeigen -

Shauna,

thank you so much for your detailed information. I now know exactly
how to work around this problem next time.
Great help. thank you. Regards, Andreas
 
A

andreas

Hi Andreas,

Shauna told you. But if there is a lot of
direct formatting and for whatever reason
you don't have the time to set it all up the proper
way, then one might think of using highlighting
to mark pieces of text in italic before you apply your
footnote style, and apply the direct formatting
afterwards again to the highlighted spots,
and remove the highlight.

Which won't work if there are pieces of text
e.g. formatted as italic plus underlined.

One might even think of setting up an array
of ranges for a footnote.
Store the italic ranges there.
Do your formatting, restore the ranges to italic.

Or a multidimensional array,
holding ranges and the formatting.

But then you would be close to re-inventing
the structure of Word-documents.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

Helmut,

as always terrific help from you. Very good information. Thank you
very much.
Regards, Andreas
 

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