我正在使用 Word 2003。
我有一个 Word 文档,从中运行宏以打开其他 Word 文档并在保存和关闭之前对其执行任务。
由于更改的数量,我一直遇到“Word 内存不足。完成此操作后,您将无法撤消此操作。是否要继续?”提示。
我已经通过谷歌搜索了这个错误,但除了以下内容外,没有找到其他信息,而这似乎在这里不起作用:
Application.DisplayAlerts = False Application.DisplayAlerts = wdAlertsNone 我认为这可能是因为该代码适用于运行宏的文档,而不是宏正在处理的文档。
下面的代码是我正在使用的代码的简化版本。我只删除了一些记录函数。
我有一个 Word 文档,从中运行宏以打开其他 Word 文档并在保存和关闭之前对其执行任务。
由于更改的数量,我一直遇到“Word 内存不足。完成此操作后,您将无法撤消此操作。是否要继续?”提示。
我已经通过谷歌搜索了这个错误,但除了以下内容外,没有找到其他信息,而这似乎在这里不起作用:
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