Results 1 to 4 of 4
  1. #1

    "Insufficient Memory" VBA Error

    I have a very large (12 MB - 2000 pages) document where I'm looping through the document once to build a couple of arrays. As I loop through the text, I'm creating Bookmarks and adding internal Hyperlinks.

    Every so often, I get an error message that says "Word has insufficient memory. You will not be able to undo this action once it is completed. Do you want to continue?". This message is displayed at the line that adds a Bookmark (Bookmarks.Add).

    If I click Yes, it will run for a while and then show the message again.

    I tried turning off Application.DisplayAlerts and using On Error Resume Next, but they had no effect.

    The script still works, but I'd like to be able to run it w/o clicking a dialog every 10 seconds. Does anyone know a way to either avoid (give Word more memory) or suppress the display of this dialog?

    Smaller files work fine and don't show me this dialog. PC memory shouldn't be a problem. I've got 128 Mb of RAM and nothing else running.

    Any help would be greatly appreciated. Thanks.


  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Silicon Valley, USA
    Thanked 94 Times in 90 Posts

    Re: Insufficient Memory VBA Error

    Since the message suggests the problems is a fat Undo buffer, try adding ActiveDocument.UndoClear to your loop.

  3. #3
    2 Star Lounger
    Join Date
    Jan 2001
    Warrington (Greater Manchester area)/Cheshire, UK
    Thanked 0 Times in 0 Posts

    Re: Insufficient Memory VBA Error

    I had a similar problem where I was just plain running out of resources.

    I solved the problem with one simple command: DoEvents

    DoEvents basically gives control back to the OS for a couple of milliseconds to allow the OS to catch with various tasks, whether it be serial/parrellel port acces, or even in this case - to clear up resources and improve memory management.

    Hope this helps!


  4. #4

    Re: Insufficient Memory VBA Error

    Thanks! The .UndoClear seemed to do the trick.

Posting Permissions

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