如何通过宏代码自动解除excel工作表格保护?
Ctrl+F11插入“宏表”MicrosoftOfficeExcel撤销密码编辑1、打开需要破解保护密码的Excel文件;2、依次点击菜单栏上的工具宏录制新宏,输入宏名字如:小A博客导航3、停止录制(这样得到一个空宏);4、依次点击菜单栏上的工具宏宏,选aa,点编辑按钮;5、删除窗口中的所有字符(只有几个),替换为下面的内容;从横线下开始复制OptionExplicitPublicSubAllInternalPasswords()Breaksworksheetandworkbookstructurepasswords。 BobMcCormickprobablyoriginatorofba...全部
Ctrl+F11插入“宏表”MicrosoftOfficeExcel撤销密码编辑1、打开需要破解保护密码的Excel文件;2、依次点击菜单栏上的工具宏录制新宏,输入宏名字如:小A博客导航3、停止录制(这样得到一个空宏);4、依次点击菜单栏上的工具宏宏,选aa,点编辑按钮;5、删除窗口中的所有字符(只有几个),替换为下面的内容;从横线下开始复制OptionExplicitPublicSubAllInternalPasswords()Breaksworksheetandworkbookstructurepasswords。
BobMcCormickprobablyoriginatorofbasecodealgorithmmodifiedforcoverageofworkbookstructure/windowspasswordsandformultiplepasswordsNormanHarkerandJEMcGimpsey27Dec2002(Version1。
1)Modified2003Apr04byJEM:Allmsgstoconstants,andeliminateoneExitSub(Version1。1。1)RevealshashedpasswordsNOToriginalpasswordsConstDBLSPACEAsStringvbNewLinevbNewLineConstAUTHORSAsStringDBLSPACEvbNewLine_AdaptedfromBobMcCormickbasecodeby_NormanHarkerandJEMcGimpseyConstHEADERAsStringAllInternalPasswordsUserMessageConstVERSIONAsStringDBLSPACEVersion1。
1。12003Apr04ConstREPBACKAsStringDBLSPACEPleasereportfailure_tothemicrosoft。public。excel。programmingnewsgroup。
ConstALLCLEARAsStringDBLSPACETheworkbookshould_nowbefreeofallpasswordprotection,somakesureyou:_DBLSPACESAVEITNOW!DBLSPACEandalso_DBLSPACEBACKUP!,BACKUP!!,BACKUP!!!_DBLSPACEAlso,rememberthatthepasswordwas_putthereforareason。
Dontstuffupcrucialformulas_ordata。DBLSPACEAccessanduseofsomedata_maybeanoffense。Ifindoubt,dont。ConstMSGNOPWORDS1AsStringTherewerenopasswordson_sheets,orworkbookstructureorwindows。
AUTHORSVERSIONConstMSGNOPWORDS2AsStringTherewasnoprotectionto_workbookstructureorwindows。DBLSPACE_Proceedingtounprotectsheets。
AUTHORSVERSIONConstMSGTAKETIMEAsStringAfterpressingOKbuttonthis_willtakesometime。DBLSPACEAmountoftime_dependsonhowmanydifferentpasswords,the_passwords,andyourcomputersspecification。
DBLSPACE_Justbepatient!Makemeacoffee!AUTHORSVERSIONConstMSGPWORDFOUND1AsStringYouhadaWorksheet_StructureorWindowsPasswordset。
DBLSPACE_Thepasswordfoundwas:DBLSPACE$$DBLSPACE_Noteitdownforpotentialfutureuseinotherworkbooksby_thesamepersonwhosetthispassword。
DBLSPACE_Nowtocheckandclearotherpasswords。AUTHORSVERSIONConstMSGPWORDFOUND2AsStringYouhadaWorksheet_passwordset。
DBLSPACEThepasswordfoundwas:_DBLSPACE$$DBLSPACENoteitdownforpotential_futureuseinotherworkbooksbysamepersonwho_setthispassword。
DBLSPACENowtocheckandclear_otherpasswords。AUTHORSVERSIONConstMSGONLYONEAsStringOnlystructure/windows_protectedwiththepasswordthatwasjustfound。
_ALLCLEARAUTHORSVERSIONREPBACKDimw1AsWorksheet,w2AsWorksheetDimiAsInteger,jAsInteger,kAsInteger,lAsIntegerDimmAsInteger,nAsInteger,i1AsInteger,i2AsIntegerDimi3AsInteger,i4AsInteger,i5AsInteger,i6AsIntegerDimPWord1AsStringDimShTagAsBoolean,WinTagAsBooleanApplication。
ScreenUpdatingFalseWithActiveWorkbookWinTag。ProtectStructureOr。ProtectWindowsEndWithShTagFalseForEachw1InWorksheetsShTagShTagOrw1。
ProtectContentsNextw1IfNotShTagAndNotWinTagThenMsgBoxMSGNOPWORDS1,vbInformation,HEADERExitSubEndIfMsgBoxMSGTAKETIME,vbInformation,HEADERIfNotWinTagThenMsgBoxMSGNOPWORDS2,vbInformation,HEADERElseOnErrorResumeNextDodummydoloopFori65To66:Forj65To66:Fork65To66Forl65To66:Form65To66:Fori165To66Fori265To66:Fori365To66:Fori465To66Fori565To66:Fori665To66:Forn32To126WithActiveWorkbook。
UnprotectChr(i)Chr(j)Chr(k)_Chr(l)Chr(m)Chr(i1)Chr(i2)_Chr(i3)Chr(i4)Chr(i5)Chr(i6)Chr(n)If。ProtectStructureFalseAnd_。
ProtectWindowsFalseThenPWord1Chr(i)Chr(j)Chr(k)Chr(l)_Chr(m)Chr(i1)Chr(i2)Chr(i3)_Chr(i4)Chr(i5)Chr(i6)Chr(n)MsgBoxApplication。
Substitute(MSGPWORDFOUND1,_$$,PWord1),vbInformation,HEADERExitDoBypassallfor。。。nextsEndIfEndWithNext:Next:Next:Next:Next:NextNext:Next:Next:Next:Next:NextLoopUntilTrueOnErrorGoTo0EndIfIfWinTagAndNotShTagThenMsgBoxMSGONLYONE,vbInformation,HEADERExitSubEndIfOnErrorResumeNextForEachw1InWorksheetsAttemptclearancewithPWord1w1。
UnprotectPWord1Nextw1OnErrorGoTo0ShTagFalseForEachw1InWorksheetsChecksforallclearShTagtriggeredto1ifnot。
ShTagShTagOrw1。ProtectContentsNextw1IfShTagThenForEachw1InWorksheetsWithw1If。ProtectContentsThenOnErrorResumeNextDoDummydoloopFori65To66:Forj65To66:Fork65To66Forl65To66:Form65To66:Fori165To66Fori265To66:Fori365To66:Fori465To66Fori565To66:Fori665To66:Forn32To126。
UnprotectChr(i)Chr(j)Chr(k)_Chr(l)Chr(m)Chr(i1)Chr(i2)Chr(i3)_Chr(i4)Chr(i5)Chr(i6)Chr(n)IfNot。ProtectContentsThenPWord1Chr(i)Chr(j)Chr(k)Chr(l)_Chr(m)Chr(i1)Chr(i2)Chr(i3)_Chr(i4)Chr(i5)Chr(i6)Chr(n)MsgBoxApplication。
Substitute(MSGPWORDFOUND2,_$$,PWord1),vbInformation,HEADERleveragefindingPwordbytryingonothersheetsForEachw2InWorksheetsw2。
UnprotectPWord1Nextw2ExitDoBypassallfor。。。
nextsEndIfNext:Next:Next:Next:Next:NextNext:Next:Next:Next:Next:NextLoopUntilTrueOnErrorGoTo0EndIfEndWithNextw1EndIfMsgBoxALLCLEARAUTHORSVERSIONREPBACK,vbInformation,HEADEREndSub复制到横线以上6、关闭编辑窗口;7、依次点击菜单栏上的工具宏宏,选AllInternalPasswords,运行,确定两次;等待大概2分钟(真的奖金2分钟),就会出现以下对话框:这就是Excel密码对应的原始密码(此密码和原先设置的密码都能打开此文档。收起