我正在尝试调整我在网上找到的代码
Sub SaveCopyas2()
Dim newWB As Variant
Dim wb1 As Workbook, wb2 As Workbook
Set wb1 = ActiveWorkbook
If wb1.Saved = False Then MsgBox wb1.FullName, vbInformation, "Workbook Not Saved"
'Set a filename for new workbook
newWB = Application.GetSaveAsFilename(ActiveWorkbook.FullName, "Excel Files (*.xls), *.xls", , "Set Filename")
If newWB <> False Then wb1.SaveCopyAs (newWB)
End Sub
这是做什么的,它允许用户通过指定位置和名称来运行宏并保存备份
我想要做的就是让它在运行宏时,文件名为“Backup”,位置为C:\
有人可以帮我修改这段代码来做我想做的事吗?
答案 0 :(得分:1)
(OP在问题编辑中回答。移入社区wiki答案。见Question with no answers, but issue solved in the comments (or extended in chat))
OP写道:这是我的工作。
Sub SaveCopyas2()
Dim newWB As Variant
Dim wb1 As Workbook
Set wb1 = ActiveWorkbook
With wb1
.SaveCopyAs ("C:\Backup.xlsm")
End With
End Sub