PDA

View Full Version : VB on Time



Me00550
07-22-2020, 07:38 AM
can someone please explain to me why this simple macro wont work unless i manually activate it? i want it to start the timer as soon a user opens the workbook


Sub OnTime()

Application.OnTime Now + TimeValue("00:15:00"), "CloseMe"
End Sub


Sub CloseMe()




ThisWorkbook.Save
ThisWorkbook.Close


End Sub

Paul_Hossler
07-22-2020, 07:45 AM
1. Not good practice to name your subs with a VBA keyword (.OnTime)

2. Did you put a call to your OnTime macro in the Workbook_Open event so that it will run when a user opens the workbook?

Me00550
07-22-2020, 09:17 AM
how do you put a call in the Workbook_Open event?

Paul_Hossler
07-22-2020, 11:31 AM
There's lots of information about Excel events online


26913

26914