Results 1 to 4 of 4
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Word has insufficient memory (Word 2002 XP)

    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

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Word has insufficient memory (Word 2002 XP)

    There is an UndoClear method, and you could run it before doing the replace. However, if the problem persists because your one replace operation makes that many changes, I don't see how you can avoid the error. Or is there a way to temporarily disable Undo altogether? Hmmm...

  3. #3
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Brussels, Brussel, Belgium
    Posts
    159
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Word has insufficient memory (Word 2002 XP)

    does application.DisplayAlerts=wdAlertsNone help?

  4. #4
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Word has insufficient memory (Word 2002 XP)

    I find this works for me:
    <pre>''' Word's "formatting" bug forces us to save our document every so often.
    ''' How often? Each 500 paragraphs seems to be the trick.
    ''' Hooray for virtual (ram) disks!
    Dim lngParagraphs As Long
    lngParagraphs = Int(ActiveDocument.Paragraphs.Count / 500)
    Dim lngOldParagraphs As Long
    If lngOldParagraphs <> lngParagraphs Then
    lngOldParagraphs = lngParagraphs
    doc.Save
    Else
    End If
    </pre>


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •