2019-09-05 doc转为docx

2019-11-15  本文已影响0人  小鱼儿spr
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')

上一篇下一篇

猜你喜欢

热点阅读