有个excel 文件忘记密码,如何才能破解打开呢?我试过用宏,可是也是不行,显示语法错误。
- 提问者网友:嘚啵嘚啵
- 2021-03-14 01:15
- 五星知识达人网友:煞尾
- 2021-03-14 01:38
- 1楼网友:逐風
- 2021-03-14 03:13
sub moveprotect() dim filename as string filename = application.getopenfilename("excel文件(*.xls & *.xla),*.xls;*.xla", , "vba破解") if filename = cstr(false) then exit sub else vbapassword filename, false end if end sub
'设置vba编码保护 sub setprotect() dim filename as string filename = application.getopenfilename("excel文件(*.xls & *.xla),*.xls;*.xla", , "vba破解") if filename = cstr(false) then exit sub else vbapassword filename, true end if end sub
private function vbapassword(filename as string, optional protect as boolean = false) if dir(filename) = "" then exit function else filecopy filename, filename & ".bak" end if
dim getdata as string * 5 open filename for binary as #1 dim cmgs as long dim dpbo as long for i = 1 to lof(1) get #1, i, getdata if getdata = "cmg=""" then cmgs = i if getdata = "[host" then dpbo = i - 2: exit for next if cmgs = 0 then msgbox "请先对vba编码设置一个保护密码...", 32, "提示" exit function end if if protect = false then dim st as string * 2 dim s20 as string * 1 '取得一个0d0a十六进制字串 get #1, cmgs - 2, st '取得一个20十六制字串 get #1, dpbo + 16, s20 '替换加密部份机码 for i = cmgs to dpbo step 2 put #1, i, st next '加入不配对符号 if (dpbo - cmgs) mod 2 <> 0 then put #1, dpbo + 1, s20 end if msgbox "文件解密成功......", 32, "提示" else dim mms as string * 5 mms = "dpb=""" put #1, cmgs, mms msgbox "对文件特殊加密成功......", 32, "提示" end if close #1 end function
在此界面直接按f5,运行moveprotect,在打开窗口中选择你说的文件,完成后,该文件的宏就没密码了。 出自 东西南北中 http://wenwen.soso.com/z/q162181032.htm