当有人关闭它时,我正在尝试使用我的excel文件。将有一个保存,所以我可以有一个用户名,日期和时间的日志我已经完成了大部分工作我想但我只是找不到这个拼图的最后一块我有以下代码但是失败一些怎么不知道为什么。
Private Sub ActiveWorkbook_Close()
Application.DisplayAlerts = False
Year_Run = Year(Date)
If Len(Month(Date)) = 1 Then Month_Run = "0" & Month(Date) Else Month_Run = Month(Date)
If Len(Day(Date)) = 1 Then Day_Run = "0" & Day(Date) Else Day_Run = Day(Date)
Date_Run = " on " & Year_Run & "-" & Month_Run & "-" & Day_Run
If Len(Hour(Time)) = 1 Then Hour_Run = "0" & Hour(Time) Else Hour_Run = Hour(Time)
If Len(Minute(Time)) = 1 Then Min_Run = "0" & Minute(Time) Else Min_Run = Minute(Time)
If Len(Second(Time)) = 1 Then Sec_Run = "0" & Second(Time) Else Sec_Run = Second(Time)
Time_Run = " at " & Hour_Run & "," & Min_Run & "," & Sec_Run
ActiveWorkbook.SaveAs ("\\Path to my folder on our network - " & (Environ$("Username")) & Date_Run & Time_Run & ".xlsm ")
End Sub
`