We know that the Aftersave event Aftersave not available for Microsoft Word. But Word allows us to use the BeforeSave event. I implemented this solution and it works great.
First, we must implement the Application.onTime method in the Word BeforeSave event as follows
Private Sub mobjWord_DocumentBeforeSave(ByVal Doc As Word.Document, SaveAsUI As Boolean, Cancel As Boolean) Word.Application.OnTime Now + TimeValue("00:00:02"), "AfterSave" End Sub
This method will call a method named Aftersave after 2 seconds.
Public Sub AfterSave() While Word.ActiveDocument.Application.BackgroundSavingStatus <> 0 DoEvents Wend 'Implement your code here End Sub
In this method, the while loop will propagate until the completion of the document saving process. This way you can implement the code after the while loop.
Nishara mj
source share