我正在显示一个加载项,将工作表复制到活动工作簿,然后再次隐藏加载项。这可以正常工作,但是当Excel工作簿关闭时,用户会询问是否要保存对加载项的更改。如何修改此语法以便始终关闭加载项而不提示保存更改?
Dim wbName As String
wbName = ActiveWorkbook.Name
ThisWorkbook.IsAddin = False
Dim LookupWB As Workbook: Set LookupWB = Application.Workbooks("URZ.xlam")
Sheets("Green").Select
ActiveSheet.Copy Before:=Workbooks(wbName).Sheets(1)
LookupWB.IsAddin = True
答案 0 :(得分:3)
您可以添加以下行:LookupWB.Saved = True
但我认为您不需要显示加载项然后隐藏它。
试试这段代码:
Sub test()
Dim Wb As Workbook: Set Wb = ActiveWorkbook
Dim LookupWB As Workbook: Set LookupWB = Application.Workbooks("URZ.xlam")
LookupWB.Sheets("Green").Copy Before:=Wb.Sheets(1)
End Sub