I am running Word 2003.
I have a Word Document, from which I run a macro that opens other Word Documents and preforms tasks on them before saving and closing them.
Because of the number of changes I keep hitting the 'Word has insufficent memory. You will not be able to undo this action once it is completed. Do you want to continue?
' prompt.
I have 'Googled' this error and haven't found anything other than the following which doesn't seem to work on this:
Application.DisplayAlerts = False
Application.DisplayAlerts =
wdAlertsNone
I think it may be because the code applies to the Document running the macro, not the document the macro is processing.
The below code is a stripped down version of the code I am using. All I have removed is some logging functions.
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
After a lot of trial and error, it was the undo buffer that was causing issue.
I put the following line within the loops that were processing the file and the message was no longer shown.
ActiveDocument.UndoClear