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

[µo°Ý] ¥¨¶°¦Û°Ê°õ¦æ

[µo°Ý] ¥¨¶°¦Û°Ê°õ¦æ

¥[¤u³Ñ¾l¼Æ.xlsm¸Ìªº¥¨¶°
Sub ³Ñ¾l¼Æ­pºâ()
....
.......
........
Call §ó·s
End Sub

Sub §ó·s()
If Time <= TimeValue("19:00:00") Then   
    Application.OnTime Now + TimeValue("00:05:00"), "³Ñ¾l¼Æ­pºâ"
  End If
End Sub

Sub µ²§ôµøµ¡()
Workbooks("¥[¤u³Ñ¾l¼Æ.xlsm").Close SaveChanges:=False
End Sub

¦pªG¦P®É¶}¤F¨â­ÓEXCELÀÉ ,·í¥uÃö±¼"¥[¤u³Ñ¾l¼Æ.xlsm",
Ä~Äò¨Ï¥Î¥t¤@­ÓECXELÀÉ®É,¨t²Î®É¶¡¨ì¤F
¤´·|¦Û°Ê¶}±Ò"¥[¤u³Ñ¾l¼Æ.xlsm"°õ¦æ"³Ñ¾l¼Æ­pºâ"

½Ð°Ý¦U¦ì«e½ú,¦³¤°»ò¤è¦¡¥i¥H µ²§ôµøµ¡§Y¤£¦b°õ¦æµ{¦¡

https://docs.microsoft.com/zh-tw/office/vba/api/excel.application.ontime
Schedule ¿ï¥Îfalse

TOP

¦^´_ 2# cody


Sub µ²§ôµøµ¡()
Application.OnTime EarliestTime:=TimeValue("00:00:10"), _
Procedure:="¸ê®Æ­éªR", Schedule:=False
'Workbooks("¥[¤u³Ñ¾l¼Æ.xlsm").Close SaveChanges:=False
End Sub

¬O³o¼Ë¼gªk¶Ü?!  ¦ý§Ú°õ¦æ®É·|¥X²{

°õ¦æ¶¥¬q¿ù»~'1004'
'OnTime'¤èªk('_Application'ª«¥ó)¥¢±Ñ

TOP

¦^´_ 2# cody


    §Ú§ä¨ì°ÝÃD¤F¡A§Ú§â¸ÑÄÀªº³æ¦r¤]¼g¤JÃø©Ç°õ¦æ¿ù»~
    §ï¦¨ Application.OnTime fireTime, "¤U¤È§ó·s", False      ´N¥i¥H¤F   :lol :lol

TOP

¦^´_ 2# cody

    Private Sub CommandButton1_Click() --¼g¦b¤u§@­¶¸Ì
    Call µ²§ôµøµ¡
     End Sub

   Sub µ²§ôµøµ¡()--¦¹µ{¦¡¬O©ñ¦b"¼Ò²Õ"¸Ì
   Application.OnTime fireTime, "¤U¤È§ó·s", False
  End Sub
  
   or

  Application.OnTime Now+ TimeValue("00:00:05"), "¤U¤È§ó·s", False

   ®É¶¡¨ì¤FÁÙ¬O·|¦Û°Ê°õ¦æ  ¬O¨º¸Ì¥X¤F°ÝÃD

TOP

RE: ¥¨¶°¦Û°Ê°õ¦æ

¦^´_  cody

    Private Sub CommandButton1_Click() --¼g¦b¤u§@­¶¸Ì
    Call µ²§ôµøµ¡
     End Su ...
annie.l µoªí©ó 2021-1-28 12:10



    ¥[¤u³Ñ¾l¼Æ-123.zip (25.66 KB)

TOP

¼Ò²Õ°Ï:
public uTime '³»ºÝ«Å§i¦@¥ÎÅܼÆ

Sub ³Ñ¾l¼Æ­pºâ()
........
Call §ó·s
End Sub

Sub §ó·s()
If Time <= TimeValue("19:00:00") Then
   uTime= Now + TimeValue("00:05:00")
    Application.OnTime uTime, "³Ñ¾l¼Æ­pºâ"
  End If
End Sub

Sub µ²§ôµøµ¡()
on error resume next
Application.OnTime uTime, "³Ñ¾l¼Æ­pºâ", Schedule:=False
on error goto 0
Workbooks("¥[¤u³Ñ¾l¼Æ.xlsm").Close SaveChanges:=False
End Sub

TOP

¦^´_ 7# ­ã´£³¡ªL


    ½Ð°Ýª©¤j  
    on error ¨â¬qªº¥Î·N¬O¤°»ò
   on error ¬Ocallµ²§ôµøµ¡Ä²µoªº¶Ü?!

   Sub µ²§ôµøµ¡()
   on error resume next
   Application.OnTime uTime, "³Ñ¾l¼Æ­pºâ", Schedule:=False
   on error goto 0
   Workbooks("¥[¤u³Ñ¾l¼Æ.xlsm").Close SaveChanges:=False
   End Sub

TOP

¦^´_ 8# annie.l


·í¤U¦¸¹w­p°õ¦æªºµ{§Ç¤£¦s¦b, ·|¤Þµo¿ù»~,
ON ERROR ¬O¥Î¨ÓÁקK¿ù»~, ¥i¤Wºô§ä»¡©ú,

TOP

¦^´_ 9# ­ã´£³¡ªL

ÁÂÁÂ §Ú¦A¤Wºô·j´M

TOP

        ÀR«ä¦Û¦b : ¡i®É¤é²öªÅ¹L¡j¤@­Ó¤H¦b¥@¶¡°µ¤F¦h¤Ö¨Æ¡A´Nµ¥©ó¹Ø©R¦³¦hªø¡C¦]¦¹¥²¶·»P®É¶¡Ävª§¡A¤Á²ö¨Ï®É¤éªÅ¹L¡C
ªð¦^¦Cªí ¤W¤@¥DÃD