我的“当前”工作簿中有一个关闭“其他”工作簿的代码。然而,“其他”工作簿有一个代码,当您关闭它时,将执行一个代码。
我想要的是,当我从“当前”工作簿运行代码时,它将绕过或忽略另一个工作簿的代码。
当前工作簿代码:
NewName = "v10.0_" & Left(CurFile, Len(CurFile) - 5)
pseudo = "'"
MacroName = "Workbook_BeforeClose"
Call SaveAs(wbk_r, NewName, FolderPath) 'Save the file to destination folder
Application.Run pseudo & NewName & "'!" & MacroName & ".xlsm", Cancel
Run Code Online (Sandbox Code Playgroud)
其他工作簿代码:'''
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If MsgBox("All data input will be permanently saved in the file database! Are you sure for your update?", vbYesNo) = vbNo Then
Exit Sub
Else
Call SaveChangesA
ThisWorkbook.Saved = True
End If
End Sub
Run Code Online (Sandbox Code Playgroud)
'''