Problem
A worksheet may contain proprietary data or algorithms that developers wish to hide from end-users. Different methods of hiding your data exist, but some methods are more secure than others.
Solution
An ExcelWriter workheet can be hidden by setting the Worksheet.Visibility property to Worksheet.SheetVisibility.Hidden. However, the worksheet can be un-hidden by users in Excel.
To make the worksheet more hidden, set Worksheet.Visibility to Worksheet.SheetVisibility.VeryHidden, in which case the worksheet will remain hidden unless the end-user writes a new VBA macro to unhide it.
Therefore, to keep a worksheet hidden, the developer must prevent end-users from creating new macros for the workbook as well. To do this, open the workbook’s macro editor and add a password to lock the project.
Password Protecting VBA in Excel 2007/2010
- Go to the Developer tab in the ribbon
- Go to Visual Basic
- Go to Tools > VBAProject Properties > Protection
- Check Lock project for viewing and add a password
Password Protecting VBA in Excel 2003
- Go to Tools > Macro > Macros
- Edit an existing macro
- In the macro editor, right-click the VBA project.
- Go to VBA Project Properties > Protection.
- Check the checkbox and add a password.
This will make it impossible for the user to look at your existing macros or to add a macro to unhide a sheet.