[python-win32] Word Automation Question

Bill Witherspoon Bill Witherspoon" <bwitherspoon@emseal.com
Wed, 23 Oct 2002 13:27:18 -0400


I had a quick scan through the 2002 archive and couldn't find anything
on this one. Please point me in the right direction.

I'm automating some label printing out of a database. Basically, its
about 7 lines on info on a 4"x4" label.

I need to control the formating by line. ie. Line 1 font = 22, line 2
font = 18, etc. I've gotten the code to work if I use:

myRange.InsertAfter(detailinfo['materialnumber'])
myRange.Sentences(2).Font.Size = 18
myRange.Sentences(2).Font.Bold = 0
myRange.Sentences(2).Font.Name = "Arial"
myRange.Sentences(2).ParagraphFormat.Alignment = 1
myRange.InsertAfter("\n")

Unfortunately, the sentences property increments whenever a period
or a newline occurs. Sometimes there's periods in the data which really
screw up the output. I figured there's got to be an easier way.

How can set the formatting line by line?

Thanks,
Bill.