- ©«¤l
- 2035
- ¥DÃD
- 24
- ºëµØ
- 0
- ¿n¤À
- 2031
- ÂI¦W
- 0
- §@·~¨t²Î
- Win7
- ³nÅ骩¥»
- Office2010
- ¾\ŪÅv
- 100
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2012-3-22
- ³Ì«áµn¿ý
- 2024-2-1
|
¦^´_ 25# n8975067 - Option Explicit
- Dim timerEnabled As Boolean ' §P©w¶}±Ò¥»¤u§@ªí³æªº®É¬q¬O§_¬°¶}½L«e±Ò°Ê¡C
- Private Sub Workbook_Open()
- timerEnabled = False
-
- Call timerStart ' µ{¦¡¤@±Ò©l¡A«K¥h¦Û°Ê°õ¦æ timerStart
- End Sub
- Private Sub Workbook_BeforeClose(Cancel As Boolean)
- On Error Resume Next
- Application.OnTime Now + TimeValue("00:00:01"), "ThisWorkbook.RTimer", , False
-
- Me.Save
- End Sub
- Sub timerStart()
- If timerEnabled Then
- ' ²Ä¤G¦¸(§t)¥H«á§¡¥H³]©w¤§ "¶¡¹j®É¬q" ¨Ó³B²z°õ¦æ§Çªº§@·~¡C
- Application.OnTime (Now + TimeValue("00:05:00")), "ThisWorkbook.updateFollow" ' ¨C¹j¤¤ÀÄÁ°õ¦æ¤@¦¸
- Else
- timerEnabled = True
-
- ' ±N²Ä¤@¦¸±Ò°Ê®É¶¡§ó§ï¬°³]©w "¶}½L®É¶¡"«e¡A¦pªG¶}±Ò Excel ®É¡A¤w¸g¹L¤F³]©w "¶}½L®É¶¡"¡A«h¤@¶i¤J¨t²Î§Yª½±µ¥h°õ¦æ¬ö¿ý§@·~¡C
- If (TimeValue(Now) <= TimeValue("08:45:00")) Then
- Application.OnTime (TimeValue("08:45:00")), "ThisWorkbook.updateFollow"
- Else
- ' ¨t²Îè³s¤W DDE ¦Ü¸ê®Æ¶×¤JExcel¤u§@ªí³æ¡A¶·¦³¤@Ó½w½Ä®É¬q¡A
- ' ³o®É¦pªG°¨¤W¥h§ì¨úDDE¸ê®Æ¡A·|¦³«¬ºA¤£²Åªº¿ù»~°T®§²£¥Í¡A¨Ã¤¤Â_°õ¦æ§Çªº§@·~¡C
- Application.OnTime (Now + TimeValue("00:00:05")), "ThisWorkbook.updateFollow"
- End If
- End If
- End Sub
- Sub updateFollow()
- Dim Rng As Range
-
- On Error Resume Next
- If (TimeValue(Now) < TimeValue("08:45:00") Or TimeValue(Now) > TimeValue("13:45:00")) Then Exit Sub
- With Sheet2
- ' Set Rng = .Range("A" & .Range("A" & .Rows.Count).End(xlUp).Row + 1)
- '
- ' Rng = Sheet1.[c2]
- ' Rng.Offset(, 1) = Sheet1.[d2]
- ' Rng.Offset(, 2) = Sheet1.[e2]
- ' Rng.Offset(, 3) = Sheet1.[f2]
- ' Rng.Offset(, 4) = Sheet1.[g2]
- ' Rng.Offset(, 5) = Sheet1.[h2]
- ' Rng.Offset(, 6) = Sheet1.[i2]
- ' Rng.Offset(, 7) = Sheet1.[j2]
- ' Rng.Offset(, 8) = Sheet1.[k2]
- ' Rng.Offset(, 9) = Sheet1.[l2]
- ' ¤W±¤§±Ôzªí¹F»P¤U¦Cªº±Ôzµ²ªG¬O¤@¼Ëªº¡A®t²§¥u¦b©ó¨Ï¥Î»yªk¤§¥©§®¤£¦P¡C
- Set Rng = .Range("A" & .Range("A" & .Rows.Count).End(xlUp).Row + 1).Resize(1, 10)
-
- Rng(1) = Sheet1.[c2]
- Rng(2) = Sheet1.[d2]
- Rng(3) = Sheet1.[e2]
- Rng(4) = Sheet1.[f2]
- Rng(5) = Sheet1.[g2]
- Rng(6) = Sheet1.[h2]
- Rng(7) = Sheet1.[i2]
- Rng(8) = Sheet1.[j2]
- Rng(9) = Sheet1.[k2]
- Rng(10) = Sheet1.[l2]
- End With
-
- If timerEnabled Then Call timerStart
- End Sub
½Æ»s¥N½X §Ú§â§Aªº updateFollow() »P§Aªº»Ý¨D¡A¥þ³¡¾ã¦X¦b¤@°_¡A
½Ð±N¥¦¥þ³¡Âл\©ó ThisWorkbook µ{¦¡½X½s¿è°Ï¶ô¤º¡C
¨C¤é 08:45:00 ¥H«e¶}±Ò¥¦ ¡A 08:45:00®É¶¡¤@¨ì¡A¨t²Î«K·|¦Û°Ê±Ò°Ê°õ¦æ¡A
13:45:00¤@¶W¹L®É¶¡¡Aµ{¦¡«K·|¦Û°Ê°±¤î¤£¦A°õ¦æ¡C
«ö¶s§A¥i¥H«O¯d¡A¦pªG¨t²Î©ó¬ðµoª¬ªp¤U°±¤î¹B§@¡A
§A¥i¥HÂI¿ï«ö¶s«ì´_¨t²Î¹B§@¡C |
|