![]() ThisWorkbook.Worksheets("No Macros").Security in Excel (XlsIO) Library (Excel Protected View) ThisWorkbook.Worksheets(LastSheet).Activate ThisWorkbook.Worksheets("No Macros").Activateįor Each Worksheet In ThisWorkbook.Worksheets ThisWorkbook.Worksheets("No Macros").Visible = xlSheetVisible Private Sub Workbook_AfterSave(ByVal Success As Boolean) Notice that I added a Variable LastSheet so when someone saves the file that it knows where to jump back to after it has unhidden all worksheets again Dim LastSheet As String ![]() The following code will hide all worksheets except "No Macros" where I have a message shown how to enable macros. Since I already made that for myself for when macros are disabled with notification, I can share it here. But you should do that at Workbook_BeforeSave because some people save it in between but don't save it in the end and then the worksheets wouldn't be hidden then next time it's opened. VBATrusted = () > 0Īs said, you can only do a workaround by hiding all Worksheets except one where it says you have to disable protected view and unhide the worksheets when macros are enabled. & "automáticamente en el lugar correcto", vbCritical & "o simplemente use la x de cerrar, y se guardará" & Chr(10) _ & "Guarde el original, usando el icono guardar," & Chr(10) _ MsgBox "NO SE PUEDE GUARDAR COMO." & Chr(10) _ Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Sheets("HojaEscondida").Range("A4") = "admin" ![]() Private Sub Workbook_BeforeClose(Cancel As Boolean) The entire ActiveWorbook code Private Sub Workbook_Open() Is there any small VBA function that does this procedure?Įrror 91 occurred at variable object runtime with block not set If > 0 Then I want at the time it is detected, to close the document until deleting that configuration of Excel. At the time of opening a document, it indicates to view it I must enable editing of the protected view. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |