我们经常使用excel的工作表保护功能,将工作表用密码保护起来,以防别人操作时进行修改,但是这样一来有可能会无法进行一些操作(如输入公式等),时间久了保护的密码也有可能忘记了,这该怎么办呢?只要按照以下步骤操作,excel工作表保护密码瞬间即破!
1、打开您需要破解保护密码的excel文件;
2、依次点击菜单栏上的工具---宏----录制新宏,输入宏名字如:aa;
3、停止录制(这样得到一个空宏);
4、依次点击菜单栏上的工具---宏----宏,选aa,点编辑按钮;
5、删除窗口中的所有字符(只有几个),替换为下面的内容;
从横线下开始复制-----------------------------
optionexplicit
publicsuballinternalpasswords()
'breaksworksheetandworkbookstructurepasswords.bobmccormick
'probablyoriginatorofbasecodealgorithmmodifiedforcoverage
'ofworkbookstructure/windowspasswordsandformultiplepasswords
'
'normanharkerandjemcgimpsey27-dec-2002(version1.1)
'modified2003-apr-04byjem:allmsgstoconstants,and
'eliminateoneexitsub(version1.1.1)
'revealshashedpasswordsnotoriginalpasswords
constdblspaceasstring=vbnewline&vbnewline
constauthorsasstring=dblspace&vbnewline&_
"adaptedfrombobmccormickbasecodeby"&_
"normanharkerandjemcgimpsey"
constheaderasstring="allinternalpasswordsusermessage"
constversionasstring=dblspace&"version1.1.12003-apr-04"
constrepbackasstring=dblspace&"pleasereportfailure"&_
"tothemicrosoft.public.excel.programmingnewsgroup."
constallclearasstring=dblspace&"theworkbookshould"&_
"nowbefreeofallpasswordprotection,somakesureyou:"&_
dblspace&"saveitnow!"&dblspace&"andalso"&_
dblspace&"backup!,backup!!,backup!!!"&_
dblspace&"also,rememberthatthepasswordwas"&_
"putthereforareason.don'tstuffupcrucialformulas"&_
"ordata."&dblspace&"accessanduseofsomedata"&_
"maybeanoffense.ifindoubt,don't."
constmsgnopwords1asstring="therewerenopasswordson"&_
"sheets,orworkbookstructureorwindows."&authors&version
constmsgnopwords2asstring="therewasnoprotectionto"&_
"workbookstructureorwindows."&dblspace&_
"proceedingtounprotectsheets."&authors&version
constmsgtaketimeasstring="afterpressingokbuttonthis"&_
"willtakesometime."&dblspace&"amountoftime"&_
"dependsonhowmanydifferentpasswords,the"&_
"passwords,andyourcomputer'sspecification."&dblspace&_
"justbepatient!makemeacoffee!"&authors&version
constmsgpwordfound1asstring="youhadaworksheet"&_
"structureorwindowspasswordset."&dblspace&_
"thepasswordfoundwas:"&dblspace&"$$"&dblspace&_
"noteitdownforpotentialfutureuseinotherworkbooksby"&_
"thesamepersonwhosetthispassword."&dblspace&_
"nowtocheckandclearotherpasswords."&authors&version
constmsgpwordfound2asstring="youhadaworksheet"&_
"passwordset."&dblspace&"thepasswordfoundwas:"&_
dblspace&"$$"&dblspace&"noteitdownforpotential"&_
"futureuseinotherworkbooksbysamepersonwho"&_
"setthispassword."&dblspace&"nowtocheckandclear"&_
"otherpasswords."&authors&version
constmsgonlyoneasstring="onlystructure/windows"&_
"protectedwiththepasswordthatwasjustfound."&_
allclear&authors&version&repback
dimw1asworksheet,w2asworksheet
dimiasinteger,jasinteger,kasinteger,lasinteger
dimmasinteger,nasinteger,i1asinteger,i2asinteger
dimi3asinteger,i4asinteger,i5asinteger,i6asinteger
dimpword1asstring
dimshtagasboolean,wintagasboolean
application.screenupdating=false
withactiveworkbook
wintag=.protectstructureor.protectwindows
endwith
shtag=false
foreachw1inworksheets
shtag=shtagorw1.protectcontents
nextw1
ifnotshtagandnotwintagthen
msgboxmsgnopwords1,vbinformation,header
exitsub
endif
msgboxmsgtaketime,vbinformation,header
ifnotwintagthen
msgboxmsgnopwords2,vbinformation,header
else
onerrorresumenext
do'dummydoloop
fori=65to66:forj=65to66:fork=65to66
forl=65to66:form=65to66:fori1=65to66
fori2=65to66:fori3=65to66:fori4=65to66
fori5=65to66:fori6=65to66:forn=32to126
withactiveworkbook
.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.protectstructure=falseand_
.protectwindows=falsethen
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)
msgboxapplication.substitute(msgpwordfound1,_
"$$",pword1),vbinformation,header
exitdo'bypassallfor...nexts
endif
endwith
next:next:next:next:next:next
next:next:next:next:next:next
loopuntiltrue
onerrorgoto0
endif
ifwintagandnotshtagthen
msgboxmsgonlyone,vbinformation,header
exitsub
endif
onerrorresumenext
foreachw1inworksheets
'attemptclearancewithpword1
w1.unprotectpword1
nextw1
onerrorgoto0
shtag=false
foreachw1inworksheets
'checksforallclearshtagtriggeredto1ifnot.
shtag=shtagorw1.protectcontents
nextw1
ifshtagthen
foreachw1inworksheets
withw1
if.protectcontentsthen
onerrorresumenext
do'dummydoloop
fori=65to66:forj=65to66:fork=65to66
forl=65to66:form=65to66:fori1=65to66
fori2=65to66:fori3=65to66:fori4=65to66
fori5=65to66:fori6=65to66:forn=32to126
.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.protectcontentsthen
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)
msgboxapplication.substitute(msgpwordfound2,_
"$$",pword1),vbinformation,header
'leveragefindingpwordbytryingonothersheets
foreachw2inworksheets
w2.unprotectpword1
nextw2
exitdo'bypassallfor...nexts
endif
next:next:next:next:next:next
next:next:next:next:next:next
loopuntiltrue
onerrorgoto0
endif
endwith
nextw1
endif
msgboxallclear&authors&version&repback,vbinformation,header
endsub
----------------------
复制到横线以上
6、关闭编辑窗口;
7、依次点击菜单栏上的工具---宏-----宏,选allinternalpasswords,运行,确定两次;