Inconsistent style behavior in Word 2003

S

seabird

I am creating a word document from a source accessed by a Ruby program. It
mostly works, but occasionally Word gets the style wrong.

This is most commonn with some of the heading styles. Fior example, my
Heading 3 style is defined to use "Body Text" as the "Style for Following
Paragraphs:"

In my code, I explicitly set the style for each block of text I send. The
attached snippet shows that happening:

def s(style,text)
@wordDoc.Range.Style = style
@wordDoc.TypeText(text << "\n")
@wordDoc.Range.Style = "Body Text"
end

Every once in a while, Word refuses to acknowledge the style that I am
passing into the s() method. Instead it uses the style that is the "following
paragraph" style from the previous text block.

I would be tenmpted to believe that this was a pure programming error on my
part, however I have some evidence that it may not be.

It happens inconsistently. The same loop is executed with different values
and Word chooses to just get a few of them wrong. So in a 1000 page document
(don't ask!), about 10 of the blocks will exhibit this behavior.

I have also noticed that this situation can occur when I am typing by hand
and set up something to use a specific style. Word will sometimes (not
consistently) get the following style wrong and give me something quite
unexpected.

Any ideas gratefully received.

Thanks

Chris
 
S

Stefan Blom

In Word, the "Style for following paragraph" is applied as you press
Enter at the end of a paragraph. If you press Enter before the end
of the paragraph, the "Style for following paragraph" is not applied;
instead, Word assumes that you want to split the existing paragraph.

Whether a piece of text is in fact a paragraph is determined by the
presence of paragraph marks (¶). In the user interface, you can see
those if you enable the display of nonprinting marks: press the ¶
button on the Standard toolbar. (For more, see
http://word.mvps.org/faqs/formatting/NonPrintChars.htm.)

For specific help with coding, a programming newsgroup such as
microsoft.public.word.vba.general would be more useful.

--
Stefan Blom
Microsoft Word MVP


in message
news:[email protected]...
 

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