Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) '指定Excel文件的路径 XlsFilePath = "D:" '指定备份路径 BackupXlsFilePath = "E:" If ThisWorkbook.Path = XlsFilePath Then ExcelFilePath = BackupXlsFilePath Else ExcelFilePath = XlsFilePath End If '提示是否备份 Response = MsgBox("保存时是否备份当前Excel文件?" & vbCr & "备份位置:" & ExcelFilePath, vbYesNo, "提示备份") If Response = vbYes Then ' 用户按下“是” '两个Excel文件相互备份 ThisWorkbook.SaveCopyAs Filename:=ExcelFilePath & "\" & ThisWorkbook.Name End If End Sub