vi_srikanth
asked on
VBA - Document Change/Key Press
Hi Friends
In Microsoft Word is there a way by which I can trap whenever a change(Insertion/Deletion/ Modificati on) happens in my document? Is there a way in VBA to handle this?
If this is not possible, is there a way by which I can trap the key pressed in my document thru VBA?
Please help me.
Srik
In Microsoft Word is there a way by which I can trap whenever a change(Insertion/Deletion/
If this is not possible, is there a way by which I can trap the key pressed in my document thru VBA?
Please help me.
Srik
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks a lot.
But, it is pity that there is no EVENT to handle this!
But, it is pity that there is no EVENT to handle this!
I agree, It surprised me how little there was.
Thanks for the grade!
MD
Thanks for the grade!
MD
Put the following code in ThisDocument module. I don't know enough regarding problems looping macros like this continually, so its at your own risk. The code will check each 5 seconds for a change, then show a message box and save it. Change the interval/action to suit your needs
MD
Private Sub Document_Open()
Application.OnTime When:=Now + TimeValue("00:00:05"), _
Name:="Check1"
End Sub
Sub Check1()
Application.OnTime When:=Now + TimeValue("00:00:05"), _
Name:="Check2"
If ActiveDocument.Saved = False Then
MsgBox Now()
ActiveDocument.Save
End If
End Sub
Sub Check2()
Application.OnTime When:=Now + TimeValue("00:00:05"), _
Name:="Check1"
If ActiveDocument.Saved = False Then
MsgBox Now()
ActiveDocument.Save
End If
End Sub