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

[µo°Ý] ¹H¤Ï¦@¥Î­ì«h

[µo°Ý] ¹H¤Ï¦@¥Î­ì«h

½Ð°Ý½×¾Âªº¤j¤j­Ì
"¹H¤Ï¦@¥Î­ì«h"¬O¬Æ»ò·N«ä


¥[¤J©³¤Uªº»yªk´N·|¥X²{"¹H¤Ï¦@¥Î­ì«h"
Private Sub Workbook_Open()
Application.OnTime TimeValue("17:00:00"), "full_calc"
End Sub

»yªkªº¨Ó·½
https://learn.microsoft.com/zh-tw/office/vba/api/excel.application.ontime

¦^´_ 1# cowww

Function IsFileOpen(filePath As String) As Boolean
    Dim fileNum As Integer
    fileNum = FreeFile()

    On Error Resume Next
    Open filePath For Binary Access Read Write Lock Read Write As fileNum
    If Err.Number <> 0 Then
        IsFileOpen = True
    End If
    Close fileNum
    On Error GoTo 0
End Function

Dim targetFilePath As String
    targetFilePath = "\\shl-group.com\dept\MFMG\¹ï¥~³æ¦ì¶}©ñ¸ê®Æ\·|ij«Ç¼Ò¨ã°lÂܸê°T\«æ¥ó±M®×ª¬ºA°lÂÜ_v2_1.xlsm"
   
If IsFileOpen(targetFilePath) Then
    ' Àɮפw³Q¶}±Ò¡A°õ¦æ¥t¦s·sÀɪº°Ê§@
    Dim currentDate As String
    currentDate = Format(Date, "yyyymmdd") ' ¨ú±o·í¤Ñ¤é´Áªº¦r¦êªí¥Ü¡A¨Ò¦p¡G20230522
   
    Dim newFileName As String
    newFileName = "\\shl-group.com\dept\MFMG\¹ï¥~³æ¦ì¶}©ñ¸ê®Æ\·|ij«Ç¼Ò¨ã°lÂܸê°T\«æ¥ó±M®×ª¬ºA°lÂÜ_v2_1_" & currentDate & ".xlsm"
   
    ThisWorkbook.SaveAs filename:=newFileName, WriteResPassword:="6112", ReadOnlyRecommended:=True

Else
    ThisWorkbook.SaveAs filename:=targetFilePath, WriteResPassword:="6112", ReadOnlyRecommended:=True

End If
============================================================================================
Private Sub Workbook_Open()

'«ü©w07:45¶}©l°õ¦æ"full_calc"
    Application.OnTime TimeValue("17:00:00"), "full_calc"
   
End Sub

´ú¸Õµo²{¤W­z¨â¬q»yªk¦n¹³·|³y¦¨"¹H¤Ï¦@¥Î­ì«h"ªº²§±`¥X²{

½Ð°Ý³o­Ó°ÝÃD¦³¿ìªk¸Ñ¨M¶Ü??

TOP

¦^´_ 2# cowww


    ­Y§Ú¨S°O¿ù ³o¸Ì¥i¯à¦³¨â­Ó¿ù»~
1.®É¶¡µ¥«Ý §Ú«Øij¬O Application.OnTime date+TimeValue("17:00:00"), "full_calc"


2.¥Ñ©ó³o¸Ìªº®Ñ¼g¤è¦¡»Pcall ªº¤è¦¡¤£¦P  ¤ñ¸ûÃþ¦üvb
¨Ò¦p»¡ ¬Y­Ó¼Ò²Õ moduel1 ·í¤¤ªº sub test() µ{§Ç
¨º´N¸Ó¼g¦¨
Application.OnTime date+TimeValue("17:00:00"), "moduel1.test"
¦Ó¤£¯à¼g¦¨
Application.OnTime date+TimeValue("17:00:00"), "test"

TOP

¦^´_ 3# singo1232001

«D±`·PÁÂsingo1232001¤j¤jªº¸Ñ´b

ÁÙ¬O·|¥X²{"¹H¤Ï¦@¥Î­ì«h"ªº¿ù»~°T®§

TOP

¥»©«³Ì«á¥Ñ singo1232001 ©ó 2023-8-11 14:08 ½s¿è

¦^´_ 4# cowww


¦]¬°¨S¦³¬Ý¨ìfull_calcªº¼Ò²Õ  ©Ò¥HµLªk§PÂ_

¦ý§Ú¤£«Øij §âontime ¼g¦bThisworkbook¼Ò²Õ¤º
À³§ï¼g¦b¦Û­q¼Ò²Õ¤U
¦Ó¦bopenªº®É­Ô ¥hcall©I¥s³o­Ó¼Ò²Õ

TOP

¦^´_ 5# singo1232001

§Ú¤]¬Oı±o¼g¦bopen©³¤U¤ñ¸û¦n
¦ý¬O§Ú¦b¤½¥q¹q¸£ªºÅv­­¥u¦³¨Ï¥ÎªÌ
¨S¿ìªk°µWindows¤u§@±Æµ{¾¹

©Ò¥H¤~·|·Q¨ì¥Îontime

TOP

¦^´_ 6# cowww


·Pı¤W ontime³o¥y»yªk¨S°ÝÃD

¦Ó¬O¦b³o full_calc ­Óµ{§Ç¸Ì­±¥X¿ù

¦bfull_calc¥X¿ù ³Q¼u¥X¨Ó ontime³oÃä ·|»~»{¥H¬°¬Oontime¥X¿ù  

À³¸Ó¥ý¥t¥~¼g¤@­Óª½±µ´ú¸Õ¤£­n¥Îontimeªº¤è¦¡ call full_calc ³v¦æF8¬Ý¬Ý

sub testcall
call full_calc
end sub

TOP

¦^´_ 1# cowww


    ¥i¯à¬O¸ê®Æ§¨¦@¥Î¡BÀɮצ@¥ÎÅv­­°ÝÃD¡A
¥i¥H¸Õ¸Õ½Æ»s¤@­ÓÀɮרì¥t³B¡A¸ê®Æ§¨¡BÀɮ׬Ҥ£¯à¬O¦@¥Î¡C

TOP

¦^´_ 7# singo1232001


«D±`·PÁÂsingo1232001¤j¤jªº¸Ñ´b
¤U­±ªº¼gªk¨Ã¨S¦³¥X²{"¹H¤Ï¦@¥Î­ì«h"
Sub ±M®×_«ö¶s22_Click()
Call full_calc
End Sub

TOP

¦^´_ 8# goner

«D±`·PÁÂgoner¤j¤jªº¸Ñ´b

§Ú¬O¥t¦s¤@­ÓÀÉ®×°µ­×§ï
¤]«Ü½T©wÀɮרèS¦³¶}°_¦@¥Î

TOP

        ÀR«ä¦Û¦b : ¦³¤ß´N¦³ºÖ¡A¦³Ä@´N¦³¤O¡A¦Û³yºÖ¥Ð¡A¦Û±oºÖ½t¡C
ªð¦^¦Cªí ¤W¤@¥DÃD