diggerdidoodar
Board Regular
- Joined
- May 20, 2002
- Messages
- 59
Got the following code off the forum which works great to run the macro evey 10 seconds.
What I really want is to run it at a certain time in the morning
Can anyone please help
PS:- The actual code procedure code is just a test, I don't really want to write my name 100's of times.
Public Declare Function SetTimer Lib "user32" ( _
ByVal HWnd As Long, ByVal nIDEvent As Long, _
ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Public Declare Function KillTimer Lib "user32" ( _
ByVal HWnd As Long, ByVal nIDEvent As Long) As Long
Public TimerID As Long
Public TimerSeconds As Single
Sub StartTimer()
TimerSeconds = 10 ' how often to "pop" the timer.
TimerID = SetTimer(0&, 0&, TimerSeconds * 1000&, AddressOf TimerProc)
End Sub
Sub EndTimer()
On Error Resume Next
KillTimer 0&, TimerID
End Sub
Sub TimerProc(ByVal HWnd As Long, ByVal uMsg As Long, _
ByVal nIDEvent As Long, ByVal dwTimer As Long)
'
Workbooks.Open Filename:= _
"C:\Documents and Settings\ddignum.RENOLD_GEARS\My Documents\Book2.xls"
Range("C6").Select
ActiveCell.FormulaR1C1 = "D a v I d"
Range("C6").Select
Selection.AutoFill Destination:=Range("C6:C30"), Type:=xlFillDefault
Range("C6:C30").Select
Range("C6").Select
Selection.Copy
Range("D6").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Selection.AutoFill Destination:=Range("D6:D30"), Type:=xlFillDefault
Range("D6:D30").Select
Range("D6").Select
Selection.Copy
Range("E6").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Selection.AutoFill Destination:=Range("E6:E30"), Type:=xlFillDefault
Range("E6:E30").Select
Range("E6").Select
Selection.Copy
Range("F6").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Selection.AutoFill Destination:=Range("F6:F30"), Type:=xlFillDefault
Range("F6:F30").Select
Range("A3").Select
ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\ddignum.RENOLD_GEARS\My Documents\Book2.xls", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
ActiveWindow.Close
'
End Sub
Cheers Diggerdi
What I really want is to run it at a certain time in the morning
Can anyone please help
PS:- The actual code procedure code is just a test, I don't really want to write my name 100's of times.
Public Declare Function SetTimer Lib "user32" ( _
ByVal HWnd As Long, ByVal nIDEvent As Long, _
ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Public Declare Function KillTimer Lib "user32" ( _
ByVal HWnd As Long, ByVal nIDEvent As Long) As Long
Public TimerID As Long
Public TimerSeconds As Single
Sub StartTimer()
TimerSeconds = 10 ' how often to "pop" the timer.
TimerID = SetTimer(0&, 0&, TimerSeconds * 1000&, AddressOf TimerProc)
End Sub
Sub EndTimer()
On Error Resume Next
KillTimer 0&, TimerID
End Sub
Sub TimerProc(ByVal HWnd As Long, ByVal uMsg As Long, _
ByVal nIDEvent As Long, ByVal dwTimer As Long)
'
Workbooks.Open Filename:= _
"C:\Documents and Settings\ddignum.RENOLD_GEARS\My Documents\Book2.xls"
Range("C6").Select
ActiveCell.FormulaR1C1 = "D a v I d"
Range("C6").Select
Selection.AutoFill Destination:=Range("C6:C30"), Type:=xlFillDefault
Range("C6:C30").Select
Range("C6").Select
Selection.Copy
Range("D6").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Selection.AutoFill Destination:=Range("D6:D30"), Type:=xlFillDefault
Range("D6:D30").Select
Range("D6").Select
Selection.Copy
Range("E6").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Selection.AutoFill Destination:=Range("E6:E30"), Type:=xlFillDefault
Range("E6:E30").Select
Range("E6").Select
Selection.Copy
Range("F6").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Selection.AutoFill Destination:=Range("F6:F30"), Type:=xlFillDefault
Range("F6:F30").Select
Range("A3").Select
ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\ddignum.RENOLD_GEARS\My Documents\Book2.xls", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
ActiveWindow.Close
'
End Sub
Cheers Diggerdi