Excel 2013 protect/unprotect macros on bulk sheets confirmed performance issue

kstrick9

Board Regular
Joined
Nov 5, 2012
Messages
122
There is aknown issue with Excel 2013 and a protect/unprotect all macro for large numbersof sheets. In my case, I have about 150 sheets that I run a protect all macrounder a WB Open event. In 2007 it takes seconds and in 2013 it takes about 2 to 3 minutes. <o:p></o:p>
<o:p></o:p>
Per MS development team..." this is a result of the change in Office 2013 to use a more secure encryption algorithm that takes longer to run. As a result, it takes longer to encrypt the password for password protected sheets. For single sheet protection operations this isn’t noticeable, but when add-ins or macros unlock/lock sheets in bulk the result can be noticeable. The product group has concluded that it’s something they don’t intend to fix in this version and unfortunately there are no workarounds other than to minimize the number of times you lock/unlock worksheets and only do it when they need to be modified"<o:p></o:p>
<o:p> </o:p>
I'm working on a macro as a workaround that will only verify if a sheet is protected and ifit is not protected then protect the sheet. In other words, if only one sheet isaccidentally not protected when the wb is closed the program only has to lockone sheet upon opening rather than 150. So far the following macro greatlyreduces the opening time except that I seem to be having an issue with theUserInterfaceOnly = True not sticking when the workbook is closed and reopened.For example, if a wb is closed and reopened every sheet with macros throws upan error when running the macro due to the sheet protection; hence theUserInterfaceOnly is somehow not reloading when the wb opens. HELP!<o:p></o:p>
<o:p></o:p>
Code:
Private Sub Workbook Open ()
Code:
[FONT=Calibri][COLOR=#000000]Dim x,iTotalSheets As Integer<o:p></o:p>[/COLOR][/FONT]
[FONT=Calibri][COLOR=#000000]Dim ws AsWorksheet<o:p></o:p>[/COLOR][/FONT]
[FONT=Calibri][COLOR=#000000]iTotalSheets= Worksheets.Count<o:p></o:p>[/COLOR][/FONT]
[FONT=Calibri][COLOR=#000000]For x = 1 ToiTotalSheets<o:p></o:p>[/COLOR][/FONT]
[FONT=Calibri][COLOR=#000000]    Set ws = Worksheets(x)<o:p></o:p>[/COLOR][/FONT]
[FONT=Calibri][COLOR=#000000]        If Not ws.ProtectContents Then<o:p></o:p>[/COLOR][/FONT]
[FONT=Calibri][COLOR=#000000]            ws.ProtectPassword:="password", DrawingObjects:=False, Contents:=True, Scenarios:= _<o:p></o:p>[/COLOR][/FONT]
[FONT=Calibri][COLOR=#000000]            False, UserInterfaceOnly:=True,AllowFormattingCells:=True, AllowFormattingColumns:=True,AllowFormattingRows:=True, AllowSorting:=True, AllowFiltering:=True<o:p></o:p>[/COLOR][/FONT]
[FONT=Calibri][COLOR=#000000]        End If<o:p></o:p>[/COLOR][/FONT]
[FONT=Calibri][COLOR=#000000]Next<o:p></o:p>[/COLOR][/FONT]
[FONT=Calibri][COLOR=#000000]Set ws =Nothing<o:p></o:p>[/COLOR][/FONT]
[FONT=Calibri]<o:p></o:p>[/FONT]
[FONT=Calibri][COLOR=#000000]End Sub[/COLOR][/FONT]
<o:p></o:p>
 
Last edited:

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

Forum statistics

Threads
1,215,334
Messages
6,124,325
Members
449,154
Latest member
pollardxlsm

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top