Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- word.Visible = True
- def HtmlToWord(range, soup):
- ''' Take some simple HTML and format it using COM calls '''
- text = []
- for tag in soup:
- raw_input("Step")
- if isinstance(tag, BeautifulSoup.NavigableString):
- range.Text+=str(tag)
- else:
- if tag.name == "div":
- HtmlToWord(range, tag.contents)
- elif tag.name == "br":
- #range.Text+=chr(11)
- range.InsertParagraphAfter()
- print range.Bold
- elif tag.name == "strong":
- # Make a new range
- n_range = doc.Range(Start=range.End, End=range.End)
- n_range.Text = tag.contents[0]
- n_range.Bold = True
- range = doc.Range(Start=n_range.End, End=n_range.End)
- range.Bold = False
- else:
- HtmlToWord(range, tag.contents)
- #print BeautifulSoup.BeautifulSoup(report.scope).prettify()
- HtmlToWord(doc.Bookmarks("scope").Range, BeautifulSoup.BeautifulSoup(report.scope))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement