How to intercept Save()

F

Frank Perry

Howdy,

I need to call UndoClear periodically during a process. The problem is that
the process runs for hours and Word grows to 300+ Megs and crashes before the
process finishes. Alas, I don't control what goes on in the process so I
have to find a way to clear the undo stack periodically.

I found that the Save() function is called by the background save. I can
intercept the save and make it clear the stack. How do I get my Save to
save? I tried:

Public Sub Save()
ActiveDocument.UndoClear
Application.ActiveDocument.Save
End Sub

But the save just calls itself. How do I get to the original Save?

Thanks for any help.
 
J

Jean-Guy Marcil

Frank Perry was telling us:
Frank Perry nous racontait que :
Howdy,

I need to call UndoClear periodically during a process. The problem
is that the process runs for hours and Word grows to 300+ Megs and
crashes before the process finishes. Alas, I don't control what goes

Why not?
on in the process so I have to find a way to clear the undo stack
periodically.

I found that the Save() function is called by the background save. I
can intercept the save and make it clear the stack. How do I get my
Save to save? I tried:

Public Sub Save()
ActiveDocument.UndoClear
Application.ActiveDocument.Save
End Sub

But the save just calls itself. How do I get to the original Save?

Thanks for any help.

Have you tried calling the sub FileSave()? This is the save that is called
when a user clicks on Save or does CTRL-S. I do not know if this is called
by your process.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
F

Frank Perry

Howdy,

I can't change the process because it is in a COTS package and we don't have
source code.

I have tried to intercept the Save function but when it runs, I get an error
Compiler Error:
Member already exists in an object module from which this object module
derives.

There is an earlier post to this group for a similar problem. I tried
various versions of their suggestions and I still get the error. I even
removed the Save from inside my call and still got the same error.
 
J

Jean-Guy Marcil

Frank Perry was telling us:
Frank Perry nous racontait que :
Howdy,

I can't change the process because it is in a COTS package and we
don't have source code.

I have tried to intercept the Save function but when it runs, I get
an error Compiler Error:
Member already exists in an object module from which this object
module derives.

Sounds like your COTS package (COTS?) already intercepts the FileSave
procedure...

Maybe you can try the BeforeSave event:
http://word.mvps.org/faqs/macrosvba/AppClassEvents.htm


--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

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