Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2008

Tip: Looking for answers? Try searching our database.

Releasing RAM while a macro is running

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Charlie Mac - 06 Feb 2008 20:41 GMT
VBA Gerus,

I have created a macro that scans large documents for text patterns
and adds comments when a pattern (e.g., several words) is detected. My
problem is that when it is run on documents longer than 30 pages it
slows down and on 200+ page documents, it appears to exhaust RAM and
stop.  Is it possible to release/refresh RAM while a macro is running
without erasing array and variable values?  Is there a link that
offers performance tips for macros?

Thanks from Texas
Klaus Linke - 07 Feb 2008 06:39 GMT
> VBA Gerus,
>
[quoted text clipped - 7 lines]
>
> Thanks from Texas

Hi Charlie,

I guess you're doing a lot of Find/Replace? Word can be forced to create a
lot of temporary files if you do that, so it can undo all those changes.

You could try if clearing the Undo-buffer now and then helps:
ActiveDocument.UndoClear

And/Or have the macro save the document:
ActiveDocument.Save

If your document is just text (no tables, text boxes, or fields), you could
read the whole text into a string (sText = ActiveDocument.Content.Text), and
try to do as much of the work as possible on the string rather than on the
document.
Say in the string, you find some position you want to insert text (with say
InStr), you can then set a range to that position in the document, and
insert your comment.

If these tips don't help, maybe post some code you use that's too slow...
Regards,
Klaus
Charlie Mac - 21 Feb 2008 20:10 GMT
Klaus,

Sorry it took me so long to get back....  Thank you for your
suggestion...the ActiveDocument.UndoClear works great.

Take care,

Charlie in Texas

On Thu, 7 Feb 2008 07:39:24 +0100, "Klaus Linke"
<info@fotosatz-kaufmann.de> wrote:

>> VBA Gerus,
>>
[quoted text clipped - 30 lines]
>Regards,
>Klaus
Klaus Linke - 22 Feb 2008 12:00 GMT
Glad it did the trick!

Regards,
Klaus
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.