excel工资管理系统如何进行数据备份?

excel工资管理系统

Sub AutoBackup()
Dim BackupPath As String
Dim FileName As String
Dim FilePath As String

‘设置备份路径
BackupPath = “D:\Backup\Excel工资表备份\” ‘请修改为你的备份路径

‘获取当前文件名
FileName = ThisWorkbook.Name

‘获取当前文件路径
FilePath = ThisWorkbook.FullName

‘创建备份文件名
Dim BackupFileName As String
BackupFileName = BackupPath & Left(FileName, Len(FileName) – 5) & “_” & Format(Now(), “yyyymmddhhmmss”) & “.xlsx”

‘复制文件到备份路径
FileCopy FilePath, BackupFileName

MsgBox “工资表已自动备份到:” & BackupFileName, vbInformation, “备份完成”

End Sub

Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Call AutoBackup
End Sub

利唐i人事HR社区,发布者:hiHR,转转请注明出处:https://www.ihr360.com/hrnews/20241225362.html

(0)
上一篇 1天前
下一篇 1天前

相关推荐