æ¥æºäºç¾åº¦ç¾ç§ï¼è¿æ¥å°å http://baike.baidu.com/view/1509071.htm?fromtitle=Excel&fromid=9564&type=syn
1ãæå¼éè¦ç ´è§£ä¿æ¤å¯ç çExcelæ件ï¼
ãã2ãä¾æ¬¡ç¹å»èåæ ä¸çå·¥å
·---å®----å½å¶æ°å®ï¼è¾å
¥å®ååå¦ï¼å°Aå客导èª
ãã3ãåæ¢å½å¶(è¿æ ·å¾å°ä¸ä¸ªç©ºå®)ï¼
ãã4ãä¾æ¬¡ç¹å»èåæ ä¸çå·¥å
·---å®----å®,éaa,ç¹ç¼è¾æé®ï¼
ãã5ãå é¤çªå£ä¸çææå符(åªæå 个),æ¿æ¢ä¸ºä¸é¢çå
容ï¼
ããä»æ¨ªçº¿ä¸å¼å§å¤å¶
ãã------------------------------------------------------------------------------------------
ããOption Explicit
ããPublic Sub AllInternalPasswords()
ãã' Breaks worksheet and workbook structure passwords. Bob McCormick
ãã' probably originator of base code algorithm modified for coverage
ãã' of workbook structure / windows passwords and for multiple passwords
ãã'
ãã' Norman Harker and JE McGimpsey 27-Dec-2002 (Version 1.1)
ãã' Modified 2003-Apr-04 by JEM: All msgs to constants, and
ãã' eliminate one Exit Sub (Version 1.1.1)
ãã' Reveals hashed passwords NOT original passwords
ããConst DBLSPACE As String = vbNewLine & vbNewLine
ããConst AUTHORS As String = DBLSPACE & vbNewLine & _
ãã"Adapted from Bob McCormick base code by" & _
ãã"Norman Harker and JE McGimpsey"
ããConst HEADER As String = "AllInternalPasswords User Message"
ããConst VERSION As String = DBLSPACE & "Version 1.1.1 2003-Apr-04"
ããConst REPBACK As String = DBLSPACE & "Please report failure " & _
ãã"to the microsoft.public.excel.programming newsgroup."
ããConst ALLCLEAR As String = DBLSPACE & "The workbook should " & _
ãã"now be free of all password protection, so make sure you:" & _
ããDBLSPACE & "SAVE IT NOW!" & DBLSPACE & "and also" & _
ããDBLSPACE & "BACKUP!, BACKUP!!, BACKUP!!!" & _
ããDBLSPACE & "Also, remember that the password was " & _
ãã"put there for a reason. Don't stuff up crucial formulas " & _
ãã"or data." & DBLSPACE & "Access and use of some data " & _
ãã"may be an offense. If in doubt, don't."
ããConst MSGNOPWORDS1 As String = "There were no passwords on " & _
ãã"sheets, or workbook structure or windows." & AUTHORS & VERSION
ããConst MSGNOPWORDS2 As String = "There was no protection to " & _
ãã"workbook structure or windows." & DBLSPACE & _
ãã"Proceeding to unprotect sheets." & AUTHORS & VERSION
ããConst MSGTAKETIME As String = "After pressing OK button this " & _
ãã"will take some time." & DBLSPACE & "Amount of time " & _
ãã"depends on how many different passwords, the " & _
ãã"passwords, and your computer's specification." & DBLSPACE & _
ãã"Just be patient! Make me a coffee!" & AUTHORS & VERSION
ããConst MSGPWORDFOUND1 As String = "You had a Worksheet " & _
ãã"Structure or Windows Password set." & DBLSPACE & _
ãã"The password found was: " & DBLSPACE & "$$" & DBLSPACE & _
ãã"Note it down for potential future use in other workbooks by " & _
ãã"the same person who set this password." & DBLSPACE & _
ãã"Now to check and clear other passwords." & AUTHORS & VERSION
ããConst MSGPWORDFOUND2 As String = "You had a Worksheet " & _
ãã"password set." & DBLSPACE & "The password found was: " & _
ããDBLSPACE & "$$" & DBLSPACE & "Note it down for potential " & _
ãã"future use in other workbooks by same person who " & _
ãã"set this password." & DBLSPACE & "Now to check and clear " & _
ãã"other passwords." & AUTHORS & VERSION
ããConst MSGONLYONE As String = "Only structure / windows " & _
ãã"protected with the password that was just found." & _
ããALLCLEAR & AUTHORS & VERSION & REPBACK
ããDim w1 As Worksheet, w2 As Worksheet
ããDim i As Integer, j As Integer, k As Integer, l As Integer
ããDim m As Integer, n As Integer, i1 As Integer, i2 As Integer
ããDim i3 As Integer, i4 As Integer, i5 As Integer, i6 As Integer
ããDim PWord1 As String
ããDim ShTag As Boolean, WinTag As Boolean
ããApplication.ScreenUpdating = False
ããWith ActiveWorkbook
ããWinTag = .ProtectStructure Or .ProtectWindows
ããEnd With
ããShTag = False
ããFor Each w1 In Worksheets
ããShTag = ShTag Or w1.ProtectContents
ããNext w1
ããIf Not ShTag And Not WinTag Then
ããMsgBox MSGNOPWORDS1, vbInformation, HEADER
ããExit Sub
ããEnd If
ããMsgBox MSGTAKETIME, vbInformation, HEADER
ããIf Not WinTag Then
ããMsgBox MSGNOPWORDS2, vbInformation, HEADER
ããElse
ããOn Error Resume Next
ããDo 'dummy do loop
ããFor i = 65 To 66: For j = 65 To 66: For k = 65 To 66
ããFor l = 65 To 66: For m = 65 To 66: For i1 = 65 To 66
ããFor i2 = 65 To 66: For i3 = 65 To 66: For i4 = 65 To 66
ããFor i5 = 65 To 66: For i6 = 65 To 66: For n = 32 To 126
ããWith ActiveWorkbook
ãã.Unprotect Chr(i) & Chr(j) & Chr(k) & _
ããChr(l) & Chr(m) & Chr(i1) & Chr(i2) & _
ããChr(i3) & Chr(i4) & Chr(i5) & Chr(i6) & Chr(n)
ããIf .ProtectStructure = False And _
ãã.ProtectWindows = False Then
ããPWord1 = Chr(i) & Chr(j) & Chr(k) & Chr(l) & _
ããChr(m) & Chr(i1) & Chr(i2) & Chr(i3) & _
ããChr(i4) & Chr(i5) & Chr(i6) & Chr(n)
ããMsgBox Application.Substitute(MSGPWORDFOUND1, _
ãã"$$", PWord1), vbInformation, HEADER
ããExit Do 'Bypass all for...nexts
ããEnd If
ããEnd With
ããNext: Next: Next: Next: Next: Next
ããNext: Next: Next: Next: Next: Next
ããLoop Until True
ããOn Error GoTo 0
ããEnd If
ããIf WinTag And Not ShTag Then
ããMsgBox MSGONLYONE, vbInformation, HEADER
ããExit Sub
ããEnd If
ããOn Error Resume Next
ããFor Each w1 In Worksheets
ãã'Attempt clearance with PWord1
ããw1.Unprotect PWord1
ããNext w1
ããOn Error GoTo 0
ããShTag = False
ããFor Each w1 In Worksheets
ãã'Checks for all clear ShTag triggered to 1 if not.
ããShTag = ShTag Or w1.ProtectContents
ããNext w1
ããIf ShTag Then
ããFor Each w1 In Worksheets
ããWith w1
ããIf .ProtectContents Then
ããOn Error Resume Next
ããDo 'Dummy do loop
ããFor i = 65 To 66: For j = 65 To 66: For k = 65 To 66
ããFor l = 65 To 66: For m = 65 To 66: For i1 = 65 To 66
ããFor i2 = 65 To 66: For i3 = 65 To 66: For i4 = 65 To 66
ããFor i5 = 65 To 66: For i6 = 65 To 66: For n = 32 To 126
ãã.Unprotect Chr(i) & Chr(j) & Chr(k) & _
ããChr(l) & Chr(m) & Chr(i1) & Chr(i2) & Chr(i3) & _
ããChr(i4) & Chr(i5) & Chr(i6) & Chr(n)
ããIf Not .ProtectContents Then
ããPWord1 = Chr(i) & Chr(j) & Chr(k) & Chr(l) & _
ããChr(m) & Chr(i1) & Chr(i2) & Chr(i3) & _
ããChr(i4) & Chr(i5) & Chr(i6) & Chr(n)
ããMsgBox Application.Substitute(MSGPWORDFOUND2, _
ãã"$$", PWord1), vbInformation, HEADER
ãã'leverage finding Pword by trying on other sheets
ããFor Each w2 In Worksheets
ããw2.Unprotect PWord1
ããNext w2
ããExit Do 'Bypass all for...nexts
ããEnd If
ããNext: Next: Next: Next: Next: Next
ããNext: Next: Next: Next: Next: Next
ããLoop Until True
ããOn Error GoTo 0
ããEnd If
ããEnd With
ããNext w1
ããEnd If
ããMsgBox ALLCLEAR & AUTHORS & VERSION & REPBACK, vbInformation, HEADER
ããEnd Sub
ãã-----------------------------------------------------------------------------------------
ããå¤å¶å°æ¨ªçº¿ä»¥ä¸
ãã6ãå
³éç¼è¾çªå£ï¼
ãã7ãä¾æ¬¡ç¹å»èåæ ä¸çå·¥å
·---å®-----å®ï¼éAllInternalPasswordsï¼è¿è¡ï¼ç¡®å®ä¸¤æ¬¡ï¼
ããçå¾
大æ¦2åé(ççå¥é2åé)ï¼å°±ä¼åºç°ä»¥ä¸å¯¹è¯æ¡ï¼è¿å°±æ¯Excelå¯ç 对åºçåå§å¯ç (æ¤å¯ç ååå
设置çå¯ç é½è½æå¼æ¤ææ¡£ãå¦ææ¯å«äººçææ¡£ï¼åæ³æ¢å¤å¯ç 设置ï¼å°±å¯ä»¥ç¨æ¤å¯ç è¿è¡ä¿æ¤ï¼ä»å°±è½ç¨ä»è®¾ç½®çå¯ç æå¼ï¼åæ¯ä¸å®è¦å¤§å)ï¼
åç¹å»ç¡®å®ãExcelçåå§å¯ç å°±è¢«æ¸ é¤äº!
追é®æå¼excelåï¼é¤éè¾å ¥å¯ç ï¼å¦åæ æ³ç¹å»ä»»ä½æé®å