Microsoft Excel - Is it possible to create a password on an Excel Sheet if somebody would like to open it?

Asked By maze zim on 19-Feb-13 05:00 AM
Hello,

Im creating a document wherein I would like to hide sheet2 but if someone would like to unhide-it it will prompt for a password/passcode before it displays the contents else it will go back to sheet1.

I've tried several Macro code but I'm having a hard time
Can you help me?

Thanks,
Chester
Danasegarane Arunachalam replied to maze zim on 19-Feb-13 06:47 AM
Hope this helps


http://chandoo.org/wp/2009/01/22/hide-excel-worksheet-tab/
White Ashlin replied to maze zim on 21-Feb-13 04:37 AM
If you do not want to let others edit or modify the worksheets, you can lock them by password as below code:
        Workbook workbook = new Workbook();
        workbook.LoadFromFile(@"D:\facebook.xls");
        Worksheet sheet = workbook.Worksheets[0];
        Worksheet sheet1 = workbook.Worksheets[1];
        sheet.Protect("123");
        sheet1.Protect("456");
        workbook.SaveToFile("Protected.xls");
        System.Diagnostics.Process.Start("Protected.xls");
but if you do not want to let others see the worksheet, while not want to hide it, I think the best way is to copy these sheets to another new excel sheets and encrypt the whole excel file,and delete the sheets in the original excel. you can see the detail here in source code page: http://spreadsheet.codeplex.com/