I have the following code in on a workbook.
我在工作簿上有以下代码。
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim ws As Worksheet
For Each ws In Worksheets
If ws.Name <> "Main Page" Then
ws.Visible = xlSheetHidden
End If
Next ws
ThisWorkbook.Save
End Sub
But when the workbook is next open pages that were left open at the end are still open. I don't have any other macro's or vba script that sets the pages to be unhidden yet, I'm am just doing to manually to test it.
但是当工作簿是下一个打开的页面时,最后打开的页面仍然是打开的。我没有任何其他宏或vba脚本将页面设置为未被隐藏,我只是手动测试它。
There are no errors that come up, the code complies correctly and runs. I even check the loop with breakpoints and it does go through every worksheet correctly.
没有出现错误,代码正确符合并运行。我甚至用断点检查循环,它确实正确地遍历每个工作表。
Can anyone see what might be the problem? Have I missed one vital key word or something? Its driving me nuts, worse than trying to track down ; in c#
任何人都可以看到可能是什么问题?我错过了一个重要的关键词还是什么?它让我疯狂,比试图追踪更糟糕;在c#中
Ask any questions you think would help.
询问您认为有用的任何问题。
Matt
2 个解决方案
#1
0
you should try something like
你应该尝试类似的东西
ws.Visible = xlSheetVeryHidden
#2
0
Check if the workbook is protected. If it's protected, you have to unprotect the workbook first.
检查工作簿是否受保护。如果受保护,则必须先取消保护工作簿。
#1
0
you should try something like
你应该尝试类似的东西
ws.Visible = xlSheetVeryHidden
#2
0
Check if the workbook is protected. If it's protected, you have to unprotect the workbook first.
检查工作簿是否受保护。如果受保护,则必须先取消保护工作簿。