I don't see any reason to have the Class Module.
You have to run a macro with the Applicaton.OnTime command to schedule an
event. See Chip Pearson's page on application.OnTime
http://www.cpearson.com/excel/ontime.htm
When excel is closed, any ontime events are lost - your sample code doesn't
specify a date so it is unclear what a specific date and time means.
--
Regards,
Tom Ogilvy
"lobo" <mbentler@gmail.com> wrote in message
news:1134746452.762117.102140@g49g2000cwa.googlegroups.com...
> I have a macro, that works, that I want to run on a certain day at a
> certain time, but can't find a way to trigger it.
> Tried
> Application.OnTime
> I have a Class Module with
>
> Public WithEvents xlApp As Application
>
> Private Sub Class_Initialize
>
> Set XL.xlApp = Application
>
> Module
>
> Application.OnTime(9:00 AM),"Date_Lock", , = True
>
> Sub Date_Lock()
> ActiveSheet.Select
> Range("C3:W384").Select
> Range("C349").Activate
> Selection.Locked = True
> Selection.FormulaHidden = True
> ActiveWorkbook.Save
> ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
> Scenarios:=True
> ActiveSheet.EnableSelection = xlNoSelection
> End Sub
>
> Date _Lock works when manually run, but won't trigger when I want?
>
Bookmarks