3

我正在运行 Word 2003。

我有一个 Word 文档,我从中运行一个宏,该宏可以打开其他 Word 文档并在保存和关闭它们之前对其执行任务。

由于更改的数量,我不断点击“ Word has insufficent memory. You will not be able to undo this action once it is completed. Do you want to continue?”提示。

我已经“用谷歌搜索”了这个错误,除了以下似乎不起作用的东西之外,我没有发现任何其他东西:

  • Application.DisplayAlerts = False
  • Application.DisplayAlerts = wdAlertsNone

我认为这可能是因为代码适用于运行宏的文档,而不是宏正在处理的文档。

下面的代码是我正在使用的代码的精简版本。我删除的只是一些日志记录功能。

Function open_word_file(file_name)

    Call wd_backup_current_file_first(file_name) ' backup the current file - so that if damage is done, it can be undone.

    Documents.Open FileName:=file_name, ConfirmConversions:=False, ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", WritePasswordTemplate:="", Format:=wdOpenFormatAuto, XMLTransform:=""


    Application.DisplayAlerts = False
    'Application.DisplayAlerts = wdAlertsNone



    '<do_work>
    Call do_something_with_the_opened_file
    '</do_work>

    ActiveDocument.Save ' save the changes
    ActiveDocument.Close
End Function
4

1 回答 1

4

经过大量的试验和错误,导致问题的是撤消缓冲区。

我将以下行放在正在处理文件的循环中,并且不再显示该消息。

ActiveDocument.UndoClear
于 2012-12-14T12:16:30.737 回答