On 14/06/2011 00:20, Tom wrote:
Hello,
I have a Javascript rich text editor (Specifically the Yahoo UI
libraries Simple Editor) which I have embedded within my web
application. This produces formatted HTML from the users input which
has to be placed within a Word document.
The number of formatting options is limited - Bold, italics,
underline, font size, font type, image insertion and lists. I thought
this would be rather simple to automate using words COM interface, but
I am having a lot of issues formatting the text using the COM
interface - my solution so far parses the HTML using BeautifulSoup and
rolls through each tag. If its a bold tag then it creates a range
object at the end of the current one, inserts the bold text and sets
the Bold attribute to True.
My issue is that this doesn't work and produces confusing results -
the text isn't formatted correctly and the Bold attribute is set to -1
(Which means a mix of both bold and non bold as far as I can tell).
Does anyone have any experience doing anything similar to this, or can
anyone give me a simpler way to do this?
It's not 100% clear whether what I'm about to suggest will help but...
Word will quite happily open (and edit) HTML directly. ie you can
File > Open > http://timgolden.me.uk/python/index.html
and the result will be an editable version of that webpage.
What's not clear is whether this would serve your purpose or
how you're getting the "formatted HTML" from your YUI editor
to the Word doc, and whether it forms part of an existing
doc.
TJG
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32