[python-win32] Word Automation Question

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


Thanks for the reply.
Here's the best I've come up with so far:
(warning: ugly and not pythonic.... but it seems to work)

...
        myRange.SetRange(totallength,totallength)
        myRange.InsertAfter (labelinfo['metricsize'] + "\n")
        totallength = totallength + len(labelinfo['metricsize'] + "\n")
        myRange.Font.Size = 14
        myRange.Font.Bold = 0
        myRange.ParagraphFormat.Alignment = 1
        myRange.Font.Name = "Arial"

        myRange.SetRange(totallength,totallength)
        myRange.InsertAfter (labelinfo['imperialsize'] + "\n")
        totallength = totallength + len(labelinfo['imperialsize'] + "\n")
        myRange.Font.Size = 14
        myRange.Font.Bold = 0
        myRange.ParagraphFormat.Alignment = 1
        myRange.Font.Name = "Arial"

and so on.........

I basically repeat the same forumula over and over.
I'll probably bury some of the repetition in a function, but I'd
still like to believe there's a better way. I thought something like:

myRange.Lines(1).Font.Size = 22
myRange.Lines(2).Font.Size = 50   #for lines 1, and 2 resp.

or

myDoc.Lines(1)....  myDoc.Lines(2)....

Thanks,
Bill.

----- Original Message -----
From: "Magnus Lycka" <magnus@thinkware.se>
To: "Bill Witherspoon" <bwitherspoon@emseal.com>; <python-win32@python.org>
Sent: Wednesday, October 23, 2002 6:16 PM
Subject: Re: [python-win32] Word Automation Question


At 13:27 2002-10-23 -0400, Bill Witherspoon wrote:
>How can set the formatting line by line?

I don't know enough of VB for Word to help with
exactly what you ask for, but I have a few ideas
on how to avoid your problem.

I could possibly imagine that using "paragraph"
instead of "sentence" might do the thing?

I typically record macros interactively in word
to see how things work.

Then I either translate that to Python *OR* I
run the Word macro from Python.

In this case I might make a Word macro that
typed a label with dummy values and did search
and replace on that with my values from Python.




--
Magnus Lyckå, Thinkware AB
Älvans väg 99, SE-907 50 UMEÅ
tel: 070-582 80 65, fax: 070-612 80 65
http://www.thinkware.se/  mailto:magnus@thinkware.se


_______________________________________________
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32