Mustafa Neemuchwala
Mustafa Neemuchwala

Reputation: 148

Convert .doc files in .docx in windows programatically using Python

I tried below code but it is giving me win32com Import Error

import win32com
word = win32com.Dispatch("Word.application")

import glob, os
os.chdir(%doc folder path%)
for file in glob.glob("*.doc"):
    file=%doc folder path%+'\\'+file
    print(file)
    doc = word.Documents.Open(file)
    file = file.replace('.doc','.docx')
    file = file.replace('DOCX_F', 'docx_files')
    doc.SaveAs(file, 16)
word.Quit()

But when I tried to install the same module it is not available

Upvotes: 2

Views: 959

Answers (1)

Shailav Shah
Shailav Shah

Reputation: 62

Try win32com.client instead of just win32com

import win32com.client
word = win32com.client.Dispatch("Word.application")

Upvotes: 1

Related Questions