Results 1 to 7 of 7
  1. #1
    4 Star Lounger
    Join Date
    Apr 2001
    Posts
    482
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Out of Memory Errors (VBA Word 2000)

    I have a macro I run to format some documents. I'll run it on one or two documents just fine. Then in the middle of running on the next document, I get:

    <pre>Run-time error '4605':

    This method or property is not available because there is a memory or disk problem.</pre>


    The line of code this happens at is totally random, so I don't think it is something in my code. It is almost like memory is being taken and not freed up.

    Any ideas how to avoid this?

    Troy

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Out of Memory Errors (VBA Word 2000)

    If you use Object variables, the kind you assign a value with

    Set varname = value

    you must release the memory they use when you're done with them:

    Set varname = Nothing

    If you use arrays, erase them when you don't need them any more:

    Erase varname

  3. #3
    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: Out of Memory Errors (VBA Word 2000)

    The other way Word/VBA consumes memory is to fill the Undo buffer. I believe there is a "clear" method for that (perhaps something.UndoClear ?) which you can use, for example, after extensive replace operations, to work around this issue.

  4. #4
    4 Star Lounger
    Join Date
    Apr 2001
    Posts
    482
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Out of Memory Errors (VBA Word 2000)

    Good idea, but I already do that.

    Thanks anyway!!
    Troy

  5. #5
    4 Star Lounger
    Join Date
    Apr 2001
    Posts
    482
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Out of Memory Errors (VBA Word 2000)

    I don't have any arrays, and I only set a few variables. In most cases, they become a block of text or a table, which is reset either when the macro ends or when the macro is run again and those variables are reset to another block of text or another table.

    Could these really be causing the out of memory?

    Thanks!!
    Troy

  6. #6
    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: Out of Memory Errors (VBA Word 2000)

    Are you using any controls or DLLs other than the usual Office/Word stuff?

  7. #7
    4 Star Lounger
    Join Date
    Apr 2001
    Posts
    482
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Out of Memory Errors (VBA Word 2000)

    Nothing special. A lot of it is creating styles, formatting text with styles, and adjusting tables. Nothing out of the ordinary. No .dlls or other controls. I don't even have any forms. I just created a custom toolbar to kick it off.

Posting Permissions

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