如果Excel文件的打开密码忘记了,且密码是7位数以内的数字,可用以下步骤解开:
新开一Excel,同时按Alt和F11,进入VBA界面,点菜单上的插入,模块,在新出来的窗口粘贴一下代码:
Sub crack()
Dim i As Long
Dim FileName As String
Application.ScreenUpdating = False
i = 1
FileName = Application.GetOpenFilename("Excel文件(*.xls & *.xlsx),*.xls;*.xlsx", , "VBA破解")
FileName = Right(FileName, Len(FileName) - InStrRev(FileName, "\"))
line2:
On Error GoTo line1
Do While True
Workbooks.Open FileName, , , , i
MsgBox "Password is " & i
Exit Sub
Loop
line1:
i = i + 1
Resume line2
Application.ScreenUpdating = True
End Sub然后直接在此界面下按F5运行此宏如果有字母,稍微复杂些,道理是类似的。太长的密码,基本解不开了。若果还有读写密码,且与打开密码一样,将Workbooks.Open FileName, , , , i 改为Workbooks.Open FileName, , , , i, i