Page 170 - Microsoft Office Excel 2003 Programming Inside Out
P. 170

Part 3:  The Excel Object Model
                                        Microsoft Office Excel 2003 Programming Inside Out

                             If you want to remove the protection from a workbook, you can do so through the Unprotect
                             method. The Unprotect method has a single parameter, the password required to unprotect
                             the workbook.

                             ActiveWorkbook.Unprotect  Password:=password
             Chapter 7
                             The following procedure lets the user attempt to unprotect a workbook:

                             Sub  UnprotectThisWkbk()
                             Dim  strPassword  As  String
                                 If  (ActiveWorkbook.ProtectStructure  =  True  Or  _
                                    ActiveWorkbook.ProtectWindows  =  True)  Then
                                    strPassword  =  InputBox  ("Type  the  password  to  remove  protection  from  _
                                        this  workbook.")
                                    ActiveWorkbook.Unprotect  Password:=strPassword
                                 Else
                                    MsgBox  ("The  workbook  is  not  protected.")
                                 End  If
                             End  Sub

                             The UnprotectThisWkbk procedure checks to see if either the ProtectStructure or the
                             ProtectWindows property is set to True because it’s possible to protect one aspect of your
                             workbook and not the other.
















                             Inside Out

                             Creating Passwords That Will Stand the Test of Time
                             The best passwords are random strings of characters, but random characters are hard to
                             remember. One good method of creating hard-to-guess passwords is to combine elements
                             of two words with a number in between. For example, you might have a password
                             prog#2003exce, which could be read as “programming version 2003 of Excel.” In any
                             event, avoid dictionary words in English or any other language, as they can be found easily
                             by password-guessing programs available on the Internet. The Excel encryption algorithm is
                             strong enough to force a cracker to spend around 30 days on average to find the key that
                             unlocks a workbook, but sensitive financial data has a significantly longer shelf life than a
                             month, so if your data is truly sensitive and you want to guard against theft or accidental
                             disclosure, you should use a stronger commercial encryption program.

                144
   165   166   167   168   169   170   171   172   173   174   175