Close file after 3 minutes?
Why doesn't this code work...
VB Code:
Public Sub Document_Open()
Application.OnTime DateAdd("n", 10, Now), SaveAndClose
End Sub
Private Function SaveAndClose()
Me.Close True
End Function
It is supposed to close a file 10 minutes after it was opened, but instead the file closes instantly.
Also, why is VBA so lame? :mad:
It does work, we use it a lot
In the OnTime method, put the name of the procedure in double quotes. Change the Function to a Sub and it should work (set to 5 secs for testing!).
VB Code:
Public Sub Document_Open()
Application.OnTime DateAdd("s", 5, Now), "SaveAndClose"
End Sub
Sub SaveAndClose()
Me.Close True
End Function