美文网首页
2019-09-05 doc转为docx

2019-09-05 doc转为docx

作者: 小鱼儿spr | 来源:发表于2019-11-15 16:53 被阅读0次
    import os
    import win32com 
    from win32com.client import Dispatch
    
    def doctodocx(filepath,newpath):
        filelist =os.listdir(filepath)
                    
        filelists=[]
        for f in filelist:
            if f.endswith('doc'):
                filelists.append(f)
        # w = win32com.client.Dispatch('Word.Application') 
        # w.Visible=0
        for f in filelists:
            filename = os.path.join(filepath,f)
            w = win32com.client.Dispatch('Word.Application') 
            w.Visible=0
            doc = w.Documents.Open(filename)
            target = newpath+'\\'+f[:-3]+'docx'
            doc.SaveAs(target,16)
    
    doctodocx(r'C:\Users\Administrator\Desktop\4',r'C:\Users\Administrator\Desktop\docx')
    
    

    相关文章

      网友评论

          本文标题:2019-09-05 doc转为docx

          本文链接:https://www.haomeiwen.com/subject/vivdyctx.html