我有这段代码:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim ws As Worksheet
Sheets("MACROS").Visible = True
For Each ws In ThisWorkbook.Worksheets
If ws.Name <> "MACROS" Then
ws.Visible = xlVeryHidden
End If
Next ws
Application.CommandBars("Ply").Enabled = True
End Sub
禁用宏时,代码显示MACROS表。问题是,当启用宏,并且已在工作簿上完成一些工作,并通过单击“X”(关闭按钮)关闭该书时,它会提示保存但显示MACROS表。
我希望在显示保存提示时让程序保持在活动工作表上。
有人会非常友好地帮助我修改上述代码吗?所有和任何帮助将不胜感激!
答案 0 :(得分:0)
删除第Sheets("MACROS").Visible = True
行。
代码应为:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
If ws.Name <> "MACROS" Then
ws.Visible = xlVeryHidden
End If
Next ws
Application.CommandBars("Ply").Enabled = True
End Sub