How to dismiss a dialog box displayed by MS Word when openning document in Python/Win32

spoonboy

I'm trying to write a script that would go though content of all ms word docs in a folder and collect some information. I use Python 2.7.3 and Ms Office 2007 The issue I have is that sometimes MS Word is coming with a warning/error popup window when opening a document. An example of the error message is 'Microsoft Visual Basic: Sub or Function not defined'. Another error is that too many grammar mistakes in the doc. These events suspend the processing until you manually press OK button. After that the scrip continues processing the document. An interesting note is that when I open the document manually in word it doesn't produce the 'Sub or Function not defined' error.

So, is there a way to suppress these errors/warnings so that the script could process the files in a batch mode?

Here is the code I use to open the word files:

import win32com.client
word = win32com.client.Dispatch("Word.Application")
word.Visible = False
...
doc = word.Documents.OpenNoRepairDialog(fname, False, True) # Popup window appears on this line
spoonboy

Ok, I have found the answer in the MS KB. It's for VB but as pywin32 is only a wrap around the API the same is applicable to the python code. Here is the link to the article in MS KB: http://support.microsoft.com/kb/259971

EDIT: since the link is dead, there is an archive of the KB here: https://www.betaarchive.com/wiki/index.php/Microsoft_KB_Archive/259971

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

NullPointerException on dialog.dismiss()

来自分类Dev

How to create a frame less Dialog box?

来自分类Dev

How to add an image to a JQuery Dialog Box

来自分类Dev

Can't copy MS Word document to my app from iOS Word app

来自分类Dev

Dismiss dialog coming from outside my application

来自分类Dev

How to Echo jQuery AJAX POST value of date in dialog box

来自分类Dev

CSS in Apps Script dialog box

来自分类Dev

IF AND语句在MS WORD中

来自分类Dev

诊断MS Word的瓶颈

来自分类Dev

MS Word图片标题宏

来自分类Dev

LaTeX用户的MS Word教程

来自分类Dev

MS Word图形编号错误

来自分类Dev

从图像创建MS Word模板

来自分类Dev

用MS Office word邮寄

来自分类Dev

MS Word表格-如何实现

来自分类Dev

在MS Word中创建脚注?

来自分类Dev

MS Word文档中的变量

来自分类Dev

MS Word中的奇怪字符¤

来自分类Dev

MS Word 2010中的目录

来自分类Dev

计算 MS Word 公式值

来自分类Dev

MS Word 宏的权限被拒绝

来自分类Dev

VBA MS Word 表格创建

来自分类Dev

从 Django 填充 MS Word 模板

来自分类Dev

如何在MS Word中使用win32com.client.constants?

来自分类Dev

需要使用 win32com 在 MS Word 中更改矩形的颜色

来自分类Dev

MS Word - excel cell, "update link" changes format. How to preserve format?

来自分类Dev

来回导航到设置屏幕时,对话框未关闭dialog.dismiss()

来自分类Dev

dialog.dismiss方法在AlertDialog中没有意义

来自分类Dev

如何使用翻新2纠正Fragment中的句柄Dialog.dismiss()