Running out of memory?

C

Charlie Mac

VBA Gerus,

I have a Word macro that loops until processing slows because memory
runs low. Is there a function to refresh/release RAM? I want to
avoid saving the file to refresh memory. Thanks.

Charlie from Texas
 
T

Tony Jollans

There is no special command to release memory; it is released when it is
finished with (as VBA sees it). If you are gradually using up memory it is
probably because you are not releasing something fully as you go. It is
impossible to say what without seeing the code but a good start is to make
sure object variables are set to Nothing when you have done with the object.

Another possibility is the Undo Stack. If you are making many changes to
documents, try using Undo.Clear from time to time.

--
Enjoy,
Tony

www.WordArticles.com

in message
news:[email protected]...
 
C

Charlie Mac

Tony,

This is my "slowing" code:

Sub Test1()
Dim MisWord As Range
For Each MisWord In ActiveDocument.SpellingErrors
ActiveDocument.UndoClear
MisWord.Select
Set NewRange = MisWord
NewRange.Comments.Add Range:=NewRange, Text:="Misspelled
Word"
Next
End Sub

Thanks.
 
T

Tony Jollans

I can only agree that you have some very slow running code there. I have no
idea why, but I don't think it's memory as it grinds to a halt for me long
before it is likely to have used all my memory. Sorry.

Presumably this is just a demonstration. What are you actually trying to do?

--
Enjoy,
Tony

www.WordArticles.com

in message
 
M

Manfred F

Hi Charlie,

Charlie Mac said:
Tony,

This is my "slowing" code:

Sub Test1()
Dim MisWord As Range
For Each MisWord In ActiveDocument.SpellingErrors
ActiveDocument.UndoClear
MisWord.Select
Set NewRange = MisWord
NewRange.Comments.Add Range:=NewRange, Text:="Misspelled
Word"
Next
End Sub

I don't think that Your PC runs out of memory while executing Your code,
because this would simply halt the system. To my experience (w2003), adding a
large number of objects to a document (paragraphs, TABLES, comments?) can
slow down word dramatically. In some cases this can be cured by cyclically
saving the document. You can try to save the doc after every 25 (try
different numbers) added comments.

Kind Regards,

Manfred
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top