ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] ¦Û°Ê°õ¦æ¥¨¶°¹J¨ì¬P´Á¤é´N°±¤î°õ¦æ

[µo°Ý] ¦Û°Ê°õ¦æ¥¨¶°¹J¨ì¬P´Á¤é´N°±¤î°õ¦æ

¤p§Ì¼g¤F¤@¬q¦Û°Ê°õ¦æ¥¨¶°ªºµ{¦¡½X¡A¦p¤U¡A
¹q¸£¡BÀɮ׳£¨SÃö¡A¨C¤ÑÅý¥¦¦Û¤v¶]¡C
¦ý¬O¤@¨ì¬P´Á¤é´N°±¤î°õ¦æ¡A
½Ð°Ý¾Çªø­Ì¡A³o¬O­þ¤Ñ¦³°ÝÃD©O?
Àµ½Ð«ü¾É¡AÁÂÁ¡C



Private Sub Workbook_Open()

Application.OnTime TimeValue("08:00:00"), "Module2.insertDataIntoMysql"
Application.OnTime TimeValue("08:10:00"), "Module2.insertDataIntoMysql"
Application.OnTime TimeValue("08:20:00"), "Module2.insertDataIntoMysql"
Application.OnTime TimeValue("08:30:00"), "Module2.insertDataIntoMysql"
Application.OnTime TimeValue("08:40:00"), "Module2.insertDataIntoMysql"
Application.OnTime TimeValue("08:50:00"), "Module2.insertDataIntoMysql"
Application.OnTime TimeValue("09:00:00"), "Module2.insertDataIntoMysql"
Application.OnTime TimeValue("09:10:00"), "Module2.insertDataIntoMysql"
Application.OnTime TimeValue("09:20:00"), "Module2.insertDataIntoMysql"
Application.OnTime TimeValue("09:30:00"), "Module2.insertDataIntoMysql"
Application.OnTime TimeValue("09:40:00"), "Module2.insertDataIntoMysql"
Application.OnTime TimeValue("09:50:00"), "Module2.insertDataIntoMysql"
Application.OnTime TimeValue("10:00:00"), "Module2.insertDataIntoMysql"
Application.OnTime TimeValue("10:10:00"), "Module2.insertDataIntoMysql"
Application.OnTime TimeValue("19:30:00"), "Module2.insertDataIntoMysql"
Application.OnTime TimeValue("20:30:00"), "Module2.insertDataIntoMysql"



End Sub

¬Ý¬Ý­þ¤@­Ó·|¦¨¥\

'======== ThisWorkbook

Private Sub Workbook_Open()
  Call MyTimerTask(Date)
End Sub


'======== Module2

Public Sub insertDataIntoMysql()  'Module2.insertDataIntoMysql
  
  Call MyTimerTask(Date + 1)

' ........ your code begin


' ........ your code end

End Sub

Private Sub Application_OnTime(EarliestTime, Procedure As String)
  If CDate(Format(EarliestTime, "hh:mm:ss")) < Time Then Exit Sub
  On Error Resume Next
  Application.OnTime EarliestTime, Procedure, , 0
  Application.OnTime EarliestTime, Procedure, , 1
End Sub

Private Sub MyTimerTask(¤é´Á As Date)

Application_OnTime ¤é´Á + TimeValue("08:00:00"), "Module2.insertDataIntoMysql"
Application_OnTime ¤é´Á + TimeValue("08:10:00"), "Module2.insertDataIntoMysql"
Application_OnTime ¤é´Á + TimeValue("08:20:00"), "Module2.insertDataIntoMysql"
Application_OnTime ¤é´Á + TimeValue("08:30:00"), "Module2.insertDataIntoMysql"
Application_OnTime ¤é´Á + TimeValue("08:40:00"), "Module2.insertDataIntoMysql"
Application_OnTime ¤é´Á + TimeValue("08:50:00"), "Module2.insertDataIntoMysql"
Application_OnTime ¤é´Á + TimeValue("09:00:00"), "Module2.insertDataIntoMysql"
Application_OnTime ¤é´Á + TimeValue("09:10:00"), "Module2.insertDataIntoMysql"
Application_OnTime ¤é´Á + TimeValue("09:20:00"), "Module2.insertDataIntoMysql"
Application_OnTime ¤é´Á + TimeValue("09:30:00"), "Module2.insertDataIntoMysql"
Application_OnTime ¤é´Á + TimeValue("09:40:00"), "Module2.insertDataIntoMysql"
Application_OnTime ¤é´Á + TimeValue("09:50:00"), "Module2.insertDataIntoMysql"
Application_OnTime ¤é´Á + TimeValue("10:00:00"), "Module2.insertDataIntoMysql"
Application_OnTime ¤é´Á + TimeValue("10:10:00"), "Module2.insertDataIntoMysql"
Application_OnTime ¤é´Á + TimeValue("19:30:00"), "Module2.insertDataIntoMysql"
Application_OnTime ¤é´Á + TimeValue("20:30:00"), "Module2.insertDataIntoMysql"

End Sub

TOP

­ì¦]¤£ª¾¹D , ¥u¯à¸Õ¸Õ¬Ý


Public Sub Workbook_Open()  ' Private  §ï  Public

For Schedule = 0 To 1
If Schedule = 0 Then On Error Resume Next

Application.OnTime TimeValue("08:00:00"), "Module2.insertDataIntoMysql", , Schedule
Application.OnTime TimeValue("08:10:00"), "Module2.insertDataIntoMysql", , Schedule
Application.OnTime TimeValue("08:20:00"), "Module2.insertDataIntoMysql", , Schedule
Application.OnTime TimeValue("08:30:00"), "Module2.insertDataIntoMysql", , Schedule
Application.OnTime TimeValue("08:40:00"), "Module2.insertDataIntoMysql", , Schedule
Application.OnTime TimeValue("08:50:00"), "Module2.insertDataIntoMysql", , Schedule
Application.OnTime TimeValue("09:00:00"), "Module2.insertDataIntoMysql", , Schedule
Application.OnTime TimeValue("09:10:00"), "Module2.insertDataIntoMysql", , Schedule
Application.OnTime TimeValue("09:20:00"), "Module2.insertDataIntoMysql", , Schedule
Application.OnTime TimeValue("09:30:00"), "Module2.insertDataIntoMysql", , Schedule
Application.OnTime TimeValue("09:40:00"), "Module2.insertDataIntoMysql", , Schedule
Application.OnTime TimeValue("09:50:00"), "Module2.insertDataIntoMysql", , Schedule
Application.OnTime TimeValue("10:00:00"), "Module2.insertDataIntoMysql", , Schedule
Application.OnTime TimeValue("10:10:00"), "Module2.insertDataIntoMysql", , Schedule
Application.OnTime TimeValue("19:30:00"), "Module2.insertDataIntoMysql", , Schedule
Application.OnTime TimeValue("20:30:00"), "Module2.insertDataIntoMysql", , Schedule

On Error GoTo 0
Next

End Sub


Sub insertDataIntoMysql()  ' Module2.insertDataIntoMysql

Call ThisWorkbook.Workbook_Open

' ........ your code begin




' ........ your code end

End Sub

TOP

¥»©«³Ì«á¥Ñ jerry045 ©ó 2018-7-31 13:14 ½s¿è

¹ï¡A¹q¸£³£¨SÃö¡A©Ò¥H¤@¹J¨ì§«ô¤é´N¤£·|°õ¦æ¤F
¦ý§Ú¥Îªº¹q¸£¬OIBMªºServer
Windows Server 2012 R2 Standard

TOP

¸£ ³sÄò7¤é³£¨SÃö ?

TOP

        ÀR«ä¦Û¦b : ¤£­nÀH¤ß©Ò±ý¡A­nÀH¤ß±Ð¨|¦Û¤v¡C
ªð¦^¦Cªí ¤W¤@¥DÃD