- ©«¤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
|
¦^´_ c_c_lai
§Ú¬O¨Ï¥ÎEASYWINªºdde°T¸¹¡A¦pªGn¨C30¬í°O¿ý¤@½ë¤W±©Ò¦³ªº¸ê®Æ¸Ó¦p¦ó¼gVBA?¦]¬°®Mªí¤W¥h ...
ribbits µoªí©ó 2012-9-9 14:31
¶K¤Wµ{¦¡½X¡A¨Ñ§A°Ñ¦Ò¡G- Option Explicit
- Dim timerEnabled As Boolean ' §P©w¶}±Ò¥»¤u§@ªí³æªº®É¬q¬O§_¬°¶}½L«e±Ò°Ê¡C
- Private Sub Workbook_Open()
- Dim Pos As Long ' ±N¨C¹j "¦h¤Ö®É¶¡" ³B²z®É¬q¡A²¾¨ì¦¹³B¨Ó³B²z¡C
- timerEnabled = False
- Pos = Sheets("Data").Range("A" & Rows.Count).End(xlUp).Row ' ¨D¥X¸ÓÄ椧³Ì«á¨Ï¥Î¦C¼Æ
- If (Pos <= 1) Then Pos = 1
- Sheets("µ¦²¤°O¿ý").[A4] = "¤w¶×¤J " & (Pos - 1) & " µ§¸ê®Æ"
- 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.ATimer", , False
-
- Me.Save
- End Sub
- Public Sub ATimer()
- Dim Pos As Long ' ±N¨C¹j "¦h¤Ö®É¶¡" ³B²z®É¬q¡A²¾¨ì¦¹³B¨Ó³B²z¡C
-
- On Error Resume Next
- ' If (TimeValue(Now) > TimeValue("13:45:00")) Then Exit Sub
-
- If (TimeValue(Now) >= TimeValue("08:45:00")) Then ' ¶}½L¡B¦¬½L®É¬q³]©w
- ' ½L¤¤³B²z¡A±N¸ê®Æ¶×¤J¼g¤J¤u§@ªí³æ¤ºÀx¦s¡C
- With Sheets("Data")
- Pos = .Range("B" & Rows.Count).End(xlUp).Row ' ¨D¥X¸ÓÄ椧³Ì«á¨Ï¥Î¦C¼Æ
- If (Pos <= 1) Then Pos = 1
- Pos = Pos + 1 ' ±NÅܰʦ渹¥[¤@¦æ
- Sheets("µ¦²¤°O¿ý").[A4] = "¤w¶×¤J " & (Pos - 1) & " µ§¸ê®Æ"
- If Not IsError(Sheets("µ¦²¤°O¿ý").[E2]) Then
- .Cells(Pos, 1) = Date ' ¤é´Á
- .Cells(Pos, 2) = Time ' ®É¶¡
- .Cells(Pos, 3) = Sheets("µ¦²¤°O¿ý").[E2] ' ¦¨¥æ»ù
- .Cells(Pos, 4).Offset(0).Resize(, 3) = Sheets("µ¦²¤°O¿ý").[G2:I2].Value
- .Cells(Pos, 7) = Sheets("µ¦²¤°O¿ý").[K2] ' ¦¨¥æ¶q
- .Cells(Pos, 8).Offset(0).Resize(, 8) = Sheets("µ¦²¤°O¿ý").[O2:V2].Value
- End If
- End With
- End If
- If timerEnabled Then Call timerStart
- End Sub
- Sub timerStart()
- If timerEnabled Then
- ' ²Ä¤G¦¸(§t)¥H«á§¡¥H³]©w¤§ "¶¡¹j®É¬q" ¨Ó³B²z°õ¦æ§Çªº§@·~¡C
- Application.OnTime (Now + TimeValue("00:00:30")), "ThisWorkbook.ATimer"
- 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.ATimer"
- 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.ATimer"
- End If
- End If
- End Sub
½Æ»s¥N½X ¦]¬°§A¥Ø«eµLÅv¤U¸ü¡A©Ò¥H±N°õ¦æµe±¶K¥Ü¡A§A¥un·ÓµÛ×¥¿§Y¥i¡G
EASYWIN0909.rar (12.11 KB)
|
|