WORD Prog: I'm running a large macro that makes hundreds of changes to a document. Getting "Out of Memory" prompts. When I OK these prompts, it continues on without issue; No real issues just have to click these 4-5 prompts as they pop up.
This memory issue would be helped if Word didn't have to log all of the changes for its UNDO function. And, besides, no one is going to go thru hundreds of UNDO steps anyway. It would be better if I could suppress the UNDO tracking functionality, and then re-invoke it when the macro is done (or errors out).
Just to be clear, I'm not talking about Tracking REVISION changes ... that's a whole different logging of changes (live to the viewer as you make the changes). I don't have that enabled anyway. I'm only talking about the UNDO button accumulation of changes.
I know about the "Sub EditUndo" macro trick to prevent using the UNDO shortcut, but this doesn't stop the accumulation of UNDO items in its queue.
Any ideas on how to do this????
Last edited by sauerj; 09-25-2010 at 09:01 AM.
Perhaps the UndoClear method.
Microsoft MVP - Excel
Entia non sunt multiplicanda sine necessitate
That clears what's been accumulated, but doesn't stop further accumulation.
No, but it should release the memory associated with the changes to date. So will saving, I believe, but this should be faster.
Microsoft MVP - Excel
Entia non sunt multiplicanda sine necessitate
I'll give it a try, Thanks!
As FYI, discovered another MEMORY SAVING tip:
Setting (Options.Pagination = False) ONLY makes any real difference if the Document View is set to Normal (doesn't help if in Print or Web View). My macro was doing a lot of Find / Replaces (refreshing Styles thru-out the doc), and I saw on the Status Bar that it was still re-paginating the doc even though I set the above to FALSE (I was in Print View and didn't know this nuance at the time). But with this new TIP (setting view to Normal in macro, then back to previous view), it now works properly (no more pagination until the very end).
In case anyone is interested, I now I intialize the macro with the following MEMORY SAVING steps:
You might be asking, "Why remove SPLIT view when you're going to shut off Screen Updating anyway?" ... Because, in split view, you can have Print View on top and Normal View on bottom. So, to avoid re-paginations, you'd have to make sure you set BOTH panes to Normal. I think it is simpler to just kill the split, minor "collateral damage" in my mind.'************* Initialize Word for least memory overhead (avoids crashes) *************** '******************* Will set view back to current settings at end ********************** Label_Initialize: ActiveWindow.Split = False 'Drop split view if active ActiveDocument.TrackRevisions = False 'Turn OFF TrackRevisions if ON If Called = True Then GoTo Skip_View_Saves ActWinView = ActiveWindow.View.Type 'Save for resetting at end DocMapView = ActiveWindow.DocumentMap 'Save for resetting at end Skip_View_Saves: ActiveWindow.View.Type = wdNormalView 'Pagination OFF only works in Normal View ActiveWindow.DocumentMap = False 'Turn of Document Map View Application.ScreenUpdating = False 'Turn OFF screen updating; turn ON at end Options.Pagination = False 'Turn OFF pagination to speed up; ON @end Application.DisplayStatusBar = True 'Make sure Status Bar is Active '****************************************************************************************
Also, discovered that these OUT OF MEMORY occurrences (answering YES to "Continue??" question) were causing the file size to grow. And, the problem was getting worse and worse, even for the most mundane non-macro tasks. So, this is not an issue to ignore. Cleaned up file by copying text & macros to New Word Document.
UPDATE! ... After installing all of the above mentioned MEMORY SAVING settings, the large FIND/REPLACE macro was STILL giving me OUT OF MEMORY alarms. I tried a few other things, then remembered SHG's UndoClear advice. I added this to execute after every iteration of FIND/REPLACE, and WOW completely eliminated the problem!
Thanks SHG! .. You and the other Forum Gurus have been such a HUGE help since I've been a member. This is such a well run and helpful forum; it is truly amazing how good and FAST you guys are! ...![]()
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks