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

[µo°Ý] ¦p¦ó±NEXCELªº§Y®É¸ê®Æ©w®É½Æ»s¨ì¤U¤è (DDE)

[µo°Ý] ¦p¦ó±NEXCELªº§Y®É¸ê®Æ©w®É½Æ»s¨ì¤U¤è (DDE)

¥»©«³Ì«á¥Ñ pipe ©ó 2012-5-31 16:06 ½s¿è

¤p§Ì§¹¥þ¤£À´VBA,·Q½Ð±Ð¦U¦ì«e½ú¤@­Ó°ÝÃD:
¨Ï¥Î¨é°ÓDDE³sµ²EXCEL,Àɮפ¤·|¦³§Y®É¸ê®Æ,¦ý¥u¦³§Y®É
§Ú·Q­n±N¥Ø«eªº¤Î®É¸ê®Æ¨C¤­¤ÀÄÁ½Æ»s¼Æ­È¶K¦b¤U¤è
¦p¤U
¡@ ¡@ ¡@

§Y®É¸ê®Æ·|¤@ª½ÅÜ°Ê,§Ú·Q­n¨C¤­¤ÀÄÁ±N§Y®ÉÄæ¦ì½Æ»s­È¶K¦b¤U¤èÄæ¦ì
±q08:30 ¤@ª½¨ì13:45, ½Ð°ÝEXCEL­n«ç»ò°µ©O??

½Ð¦U¦ì°ª¤âÀ°¦£,ÁÂÁÂ.

¦^´_ 1# pipe
½Ð°Ñ¦Ò¡G
Ãö©ó½L¤¤DDE¬ö¿ý

TOP

¥»©«³Ì«á¥Ñ pipe ©ó 2012-5-30 16:01 ½s¿è

¦^´_ 2# c_c_lai

CC¤j©êºp,§Ú§V¤Oª¦¤å¤]¬Ý§¹±zªº½d¨ÒÀÉ®×,¦ý¯uªºµLªk¹ïÀ³­×§ï¦¨§Ú¦Û¤vªº»Ý¨D, ¤@¬¤£³qªü
½Ð±zÀ°¦£­×§ï¤@¤U§Úªºªþ¥óexcel¦n¶Ü? ÁÂÁÂ!!

¸ê®Æ±q08:29:50¶}©l,¨C¤­¤ÀÄÁ©¹¤U¦s¤@µ§·í®Éªº¤Î®É¸ê®Æ"­È"(¤£¬O¤½¦¡,¤§«á¤º®e­È¤£·|¦AÅÜ°Ê),ª½¨ì¦¬½L 13:45:10

TOP

¥»©«³Ì«á¥Ñ c_c_lai ©ó 2012-5-31 20:33 ½s¿è
¦^´_  c_c_lai

CC¤j©êºp,§Ú§V¤Oª¦¤å¤]¬Ý§¹±zªº½d¨ÒÀÉ®×,¦ý¯uªºµLªk¹ïÀ³­×§ï¦¨§Ú¦Û¤vªº»Ý¨D, ¤@¬¤£³qªü ...
pipe µoªí©ó 2012-5-30 15:53

¹ê¦b¬O¯uªA¤F§A¡A·Q·QÁÙ¬OÀ°§A¼g¦n¤F¡C
  1. Option Explicit
  2. Dim timerEnabled As Boolean
  3. Dim Pos As Integer      ' ±N¨C¹j "¦h¤Ö®É¶¡" ³B²z®É¬q¡A²¾¨ì¦¹³B¨Ó³B²z¡C

  4. Private Sub Workbook_Open()
  5.     Pos = Sheets("sheet1").Range("C" & Rows.Count).End(xlUp).Row
  6.     timerEnabled = False

  7.     Call timerStart      ' µ{¦¡¤@±Ò©l¡A«K¥h¦Û°Ê°õ¦æ timerStart
  8. End Sub

  9. Private Sub Workbook_BeforeClose(Cancel As Boolean)
  10.     On Error Resume Next
  11.     Application.OnTime Now + TimeValue("00:00:01"), "ThisWorkbook.Timer", , False
  12.    
  13.     Me.Save
  14. End Sub

  15. Public Sub Timer()
  16.     On Error Resume Next
  17.     If (TimeValue(Now) > Sheets("sheet1").Range("AV2").Value) Then Exit Sub
  18.    
  19.     If (TimeValue(Now) >= Sheets("sheet1").Range("AV1").Value) Then         ' ¶}½L¡B¦¬½L®É¬q³]©w
  20.         ' ½L¤¤³B²z¡A±N¸ê®Æ¶×¤J¼g¤J¤u§@ªí³æ¤ºÀx¦s¡C

  21.         With Sheets("sheet1")
  22.             Pos = Pos + 1                  ' ±NÅܰʦ渹¥[¤@¦æ
  23.             
  24.             .Cells(Pos, 1).Value = Date     ' ¤é´Á
  25.             .Cells(Pos, 2).Value = Time     ' ®É¶¡
  26.             .Cells(Pos, 3).Resize(1, 12) = .Range("C8:N8").Value    ' ¤j§¡¡B¤j®t¡B´Á§¡¡B´Á®t¡B¥x«ü¡B°ªÂI¡B§CÂI¡B¤¤Ãö¡B»ù®t¡B®¶ºÖ¡B¼¯¥x¡B¥[Åv
  27.             
  28.             .Cells(2, 49).Value = Pos       ' AW2
  29.         End With
  30.     End If
  31.         
  32.     Call timerStart
  33. End Sub

  34. Sub timerStart()
  35.     If timerEnabled Then
  36.         Application.OnTime (Now + Sheets("sheet1").Range("AW1").Value), "ThisWorkbook.Timer"
  37.     Else
  38.         timerEnabled = True
  39.         
  40.         ' ¨t²Î­è³s¤W DDE ¦Ü¸ê®Æ¶×¤JExcel¤u§@ªí³æ¡A¶·¦³¤@­Ó½w½Ä®É¬q¡A
  41.         ' ³o®É¦pªG°¨¤W¥h§ì¨úDDE¸ê®Æ¡A·|¦³«¬ºA¤£²Åªº¿ù»~°T®§²£¥Í¡A¨Ã¤¤Â_°õ¦æ§Çªº§@·~¡C
  42.         Application.OnTime (Now + TimeValue("00:00:05")), "ThisWorkbook.Timer"
  43.     End If
  44. End Sub
½Æ»s¥N½X
°Å¤U«áª½±µ¶K¤J¨ì ThisWorkbook µ{¦¡°Ï´N OK ¤F¡C

a.rar (74 Bytes)

TOP

¦^´_ 4# c_c_lai
CC ¤j¯u­^¶¯¤]!
«H¤â©à¨Ó»´ÃP¼g¥X¤@¬qµ{¦¡,¹ï¤p§ÌÀ°§U¤Ó¤j¤F,©ú¤Ñ¶}½L®É¨Ó´ú¸Õ¤@¤U
·PÁÂCC¤jªºÀ°¦£!!

¤£¶û±óªº¸Ü,¤p§ÌÄ@·N¤À¨ÉÀ³¥Î¦b¥x«ü´Áªº°ª³Ó²v¾Ôªk(¦pªGCC¤j¦³¦bª±´Á³fªº¸Ü)
¤p§Ì¥Ø«eµLªk¤U¸üªþ¥ó,¤]µLªk±H¥X¯¸¤ºµu°T®§,Åwªï¥Î¯¸¤º«H¥óÁpô§iª¾Ápµ¸¤è¦¡!!ÁÂÁÂCC¤j!!

TOP

¦^´_ 4# c_c_lai

CC¤j,ÁöµMµ{¦¡¥i¥H»¡¬Ý¤£À´,¦ý¬O§Ú¦bµ{¦¡½X¤¤¨S¦³¬Ý¨ì 08:30 ©Î¬O 13:45 ³o¼Ëªº®É¶¡³]©w
½Ð°Ý³o­Óµ{¦¡¬O³]©w¤@¶}±Ò´N¦Û¤v°õ¦æ,¨C¤­¤ÀÄÁ°O¿ý¤@¦¸(¤£ºÞ¶}½L¦¬½L)¶Ü?

TOP

¦^´_ 6# pipe
§Aªº "AV1"¡B¥H¤Î "AV2" Äæ¦ì¤£´N¤w¸g¸ü©ú¤F¶Ü¡H
¥»¬qµ{¦¡¥¦¬O¥i¥H¥Ñ¥~³¡¨Ó±±¨îªº (¤è«K´ú¸Õ¥Î)¡A°²³]´ú¸Õ®É¶¡¬O¦b±ß¤W¤KÂI¨ì¤EÂI¤§¶¡¡A¬O¥H¨C¹j 20 ¬í¼g¤J¤@µ§¸ê®Æ¡A§A«K¥i¥H
³o»ò°µ¡A  ±N¥H¤UÄæ¦ì¤º®e²§°Ê¦¨ (¤d¸U¤£­n¥[¤W "" ²Å¸¹¡A§Yª½±µ¥´¤J 20:00:00¡B21:00:00¡B¥H¤Î 00:00:20 µ¥®É¶¡¼Æ¾Ú¡A ¥H¦¹Ãþ°ï)¡G
AV1 = "20:00:00"¡AAV2 = "21:00:00"¡A AW1 = "00:00:20"¡A µM«á¥h¦A¦æ´ú¸Õµª®×§Y¥X¡I
¼gµ{¦¡­n¤Á°O¤@ÂI¡A¤d¸U¤£­n¼g¦ºµ{¦¡¡A§_«h·|¦¨¬°¤@­ÓÙT¸}¥P¡I
My E-Mail:  [email protected]
§A¥i¥H°OÀɮר즹¡AÁÂÁ¡I

TOP

¦^´_ 7# c_c_lai

¤p§Ì²´©å,CC¤j´£¿ô«á´N¤F¸Ñ«ç»ò°µ¤F,¥Ø«e½L¤¤´ú¸Õ¤@¤ÁOK
·PÁÂCC¤jªºÀ°¦£!!

µ¥¨ì¦¬½L«á¸û¦³ªÅªº®É¶¡,¦A¸òCC¤j²á¤@¤U´Á³f

TOP

¦^´_ 8# pipe
½L¤¤´ú¸Õ
S.zip (13.96 KB)

TOP

¦^´_ 8# pipe
  1. Option Explicit
  2. Dim timerEnabled As Boolean

  3. Private Sub Workbook_Open()
  4.     timerEnabled = False

  5.     Call timerStart      ' µ{¦¡¤@±Ò©l¡A«K¥h¦Û°Ê°õ¦æ timerStart
  6. End Sub

  7. Private Sub Workbook_BeforeClose(Cancel As Boolean)
  8.     On Error Resume Next
  9.     Application.OnTime (Now + TimeValue("00:00:01")), "ThisWorkbook.Timer", , False
  10.    
  11.     Me.Save
  12. End Sub

  13. Public Sub Timer()
  14.     Dim ws As Worksheet
  15.     Dim Pos As Integer      ' ±N¨C¹j "¦h¤Ö®É¶¡" ³B²z®É¬q¡A²¾¨ì¦¹³B¨Ó³B²z¡C
  16.    
  17.     timerEnabled = True
  18.         
  19.     On Error Resume Next
  20.     Set ws = Sheets("¤u§@ªí1")
  21.     If (TimeValue(Now) > ws.Range("I2").Value) Then Exit Sub
  22.    
  23.     If (TimeValue(Now) >= ws.Range("I1").Value) Then         ' ¶}½L¡B¦¬½L®É¬q³]©w
  24.         ' ½L¤¤³B²z¡A±N¸ê®Æ¶×¤J¼g¤J¤u§@ªí³æ¤ºÀx¦s¡C

  25.         With Sheets("¤u§@ªí2")
  26.             Pos = .Range("A" & Rows.Count).End(xlUp).Row + 1   ' ±NÅܰʦ渹¥[¤@¦æ
  27.             
  28.             .Cells(Pos, 1).Value = Date        ' ¤é´Á
  29.             .Cells(Pos, 2).Value = ws.[B3]     ' ®É¶¡ (=DDEEXCEL|FUTURE!TXF16.®É¶¡)
  30.             .Cells(Pos, 3).Resize(1, 8) = ws.Range("B4:B11").Value    ' ¥«»ù    º¦¶^    º¦¶^´T  ¶}½L»ù  ³Ì°ª»ù  ³Ì§C»ù  ²Ö­p¥æ©ö¶q  ¨ÄÂ÷²v
  31.         End With
  32.     End If
  33.         
  34.     Call timerStart
  35. End Sub

  36. Sub timerStart()
  37.     If timerEnabled = False Then
  38.         Application.OnTime (Now + Sheets("¤u§@ªí1").Range("I1").Value), "ThisWorkbook.Timer"
  39.     Else
  40.         ' ¨t²Î­è³s¤W DDE ¦Ü¸ê®Æ¶×¤JExcel¤u§@ªí³æ¡A¶·¦³¤@­Ó½w½Ä®É¬q¡A
  41.         ' ³o®É¦pªG°¨¤W¥h§ì¨úDDE¸ê®Æ¡A·|¦³«¬ºA¤£²Åªº¿ù»~°T®§²£¥Í¡A¨Ã¤¤Â_°õ¦æ§Çªº§@·~¡C
  42.         Application.OnTime (Now + TimeValue("00:00:05")), "ThisWorkbook.Timer"
  43.     End If
  44. End Sub
½Æ»s¥N½X

TOP

        ÀR«ä¦Û¦b : ¦³¦h¤Ö¤O¶q´N°µ¦h¤Ö¨Æ¡A¤£­n¤ß¦sµ¥«Ý¡Aµ¥«Ý¤~·|¸¨ªÅ¡C
ªð¦^¦Cªí ¤W¤@¥DÃD