Hi
On some very large documents, eg 250 pages when running some in-house code on the Word warning message appears ” Word has insufficient memory. You will not be able to undo this action once its completed. Do you want to continue?”
Is there anyway to capture this msg before it appears and then clear the Undo buffer?
In the below code the message box is appearing on the line & is kinda in a loop. Is there a better way to perform this function without the “memory” message?
.Execute Replace:=wdReplaceAll
Public Sub CleanUPIDDFieldcodes()
Dim myStoryRange As Range
Dim strSearch As String
On Error Resume Next
strSearch = “Error! No document variable supplied.”
‘
‘ first search the main document using the Selection
‘
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = strSearch
.Replacement.Text = “”
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
End With
‘
‘ now search all other stories using Ranges
‘ this includes the headers & footers
‘
For Each myStoryRange In ActiveDocument.StoryRanges
If myStoryRange.StoryType wdMainTextStory Then
With myStoryRange.Find
.Text = strSearch
.Replacement.Text = “”
.Wrap = wdFindContinue
.Execute Replace:=wdReplaceAll
End With
Do While Not (myStoryRange.NextStoryRange Is Nothing)
Set myStoryRange = myStoryRange.NextStoryRange
With myStoryRange.Find
.Text = strSearch
.Replacement.Text = “”
.Wrap = wdFindContinue
.Execute Replace:=wdReplaceAll
End With
Loop
End If
Next myStoryRange
On Error GoTo 0
End Sub
many thanks diana