#wind32com.client is module for connecting with windows #os is module for getting information about os directory #zipfile is used to make zipfile of docx to read images because python-docx #does not provide a way to get images from docx. import win32com.client, os import zipfile wdDoNotSaveChanges = 0 #use for exist zero path = os.path.abspath('mistake_image.docx') #getting docx file directory we did not need to open it in program #because we are using word application for checking z = zipfile.ZipFile("mistake_image.docx") #making zibfile of doc for reading image and data #in this case we just need images #print all files in zip archive all_files = z.namelist() #getting all file from doc file #images will exist in side word/media/ directory that is default for maintaining images directory inside word side images = filter(lambda x: x.startswith('word/media/'), all_files) #reading only images print 'images in doc',images #printing images list on screen app = win32com.client.gencache.EnsureDispatch('Word.Application') #requesting for office grammar and spell checker #extra spaces may or may no be handle depand on spell checker #setting. if spell and grammar is not set to default . program #will show no grammar and spelling error. doc = app.Documents.Open(path) #saving path of doc file in doc object print "Grammar: %d" % (doc.GrammaticalErrors.Count,) #pring grammar error count print "Spelling: %d" % (doc.SpellingErrors.Count,) #prinng spelling errors count app.Quit(wdDoNotSaveChanges) #exist app using exit 0
[ ]{2,}
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)