我有以下脚本,它保存了我的工作簿的宏免费版本。我想要做的是将工作簿的副本保存到当前工作簿所在的同一文件夹中,使用新名称,使用相同的文件名保持当前文件打开。问题是,当前文件似乎是用新文件名覆盖的。如果我关闭Excel,然后打开新文件,它是按预期的(宏免费),我的旧工作簿也是机智。如何在不覆盖当前工作簿的情况下保存新工作簿?
sub my_Script()
' Some stuff happens here
Application.DisplayAlerts = False
Dim month As String
month = Format(ThisWorkbook.Names("rp_pd").RefersToRange(1, 1), "mmmm_yyyy")
ThisWorkbook.CheckCompatibility = False
ThisWorkbook.SaveAs Filename:=ThisWorkbook.Path & "\" & "my_report" & month & ".xlsx", FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
Application.DisplayAlerts = True
'And some more stuff happens here which will edit the ORIGINAL sheet back to how it was post save
End Sub