python docx html

#!/usr/bin/env python 
#coding=utf-8 
from win32com import client as wc 
word = wc.Dispatch('Word.Application') 
doc = word.Documents.Open(r'C:/Users/Administrator/Desktop/1.docx') 
doc.SaveAs('F:/1.html', 8) 
doc.SaveAs('F:/2.pdf', 17) 
doc.SaveAs('F:/3.html', 10) 
doc.Close() 
word.Quit()
 
'''
win32com download 
http://sourceforge.net/projects/pywin32/files/pywin32/Build%20218
        :windows xp,office 2007,python 2.5.2,pywin32 build 213,     win32com      office API,     、    ,  office    ,python     ,        office word  “   ”  。
    :http://www.fuchaoqun.com/2009/03/use-python-convert-word-to-html-with-win32com/
view source
print
?
1.#!/usr/bin/env python 
2.#coding=utf-8 
3.from win32com import client as wc 
4.word = wc.Dispatch('Word.Application') 
5.doc = word.Documents.Open('d:/labs/math.doc') 
6.doc.SaveAs('d:/labs/math.html', 8 ) 
7.doc.Close() 
8.word.Quit()
     doc.SaveAs(’d:/labs/math.html’, 8)   ,        :doc.SaveAs(’d:/labs/math.html’, win32com.client.constants.wdFormatHTML),    :
AttributeError: class Constants has no attribute ‘wdFormatHTML’
             word           (  office 2007  ,   word     PDF  , 8  17  ),   office 2007            :
wdFormatDocument = 0
wdFormatDocument97 = 0
wdFormatDocumentDefault = 16
wdFormatDOSText = 4
wdFormatDOSTextLineBreaks = 5
wdFormatEncodedText = 7
wdFormatFilteredHTML = 10
wdFormatFlatXML = 19
wdFormatFlatXMLMacroEnabled = 20
wdFormatFlatXMLTemplate = 21
wdFormatFlatXMLTemplateMacroEnabled = 22
wdFormatHTML = 8
wdFormatPDF = 17
wdFormatRTF = 6
wdFormatTemplate = 1
wdFormatTemplate97 = 1
wdFormatText = 2
wdFormatTextLineBreaks = 3
wdFormatUnicodeText = 7
wdFormatWebArchive = 9
wdFormatXML = 11
wdFormatXMLDocument = 12
wdFormatXMLDocumentMacroEnabled = 13
wdFormatXMLTemplate = 14
wdFormatXMLTemplateMacroEnabled = 15
wdFormatXPS = 18
                   ,    office 2003           。word   html       wdFormatHTML、wdFormatFilteredHTML(     8、10),      wdFormatHTML    ,word        ole       wmf  ,    wdFormatFilteredHTML          gif  ,         wdFormatFilteredHTML   HTML    wdFormatHTML     。
               com   office API,  PHP. 
'''

좋은 웹페이지 즐겨찾기