Search & Replace in MS Word Puzzle
Ola K
olakh at walla.co.il
Sun Dec 10 17:25:16 EST 2006
Waldemar Osuch wrote:
> 1. doc.Styles is a container (a build in Word object) holding instances of
> Styles (another build in Word object). One way to make the intended check
> would be.
> style_names = set(s.NameLocal for s in doc.Styles)
> if "Italic" not in style_names:
> # create style
I changed the code to that and it works perfectly! How come this is
better? I mean, I didn't find any logical or syntax problem with the
way it was before.
> 2. Read about Range object in Word VBA documentation. Range.Collapse may
> explain what happens here.
Well, so I did, and I can see now that the problem is probably that
Word takes into consideration the previous characters as well, unless I
collapse the range. However, I don't seem to find the way to properly
do it, syntax-wise. I only managed to collapse the Selection, which
didn't do the trick.
>4. This is described in py2exe wiki.
> http://www.py2exe.org/index.cgi/IncludingTypelibs
Thanks. I am now implementing this.
--Ola
More information about the Python-list
mailing list