EXCEL忘记密码怎么办?
发布时间:2023-11-04 16:13:52
1、首先打开EXCEL,选择视图,宏,录制新宏,新建一个宏,可以随便取个名字。
2、先生成一个空的宏
3、编辑这个宏,选中刚新建的宏后点击编辑按钮
4、删除窗口所有字符,把下面的内容粘贴进入。一个字母、标点符号都不能少不能错。
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
5、关闭掉编辑窗口
6、在宏里选中AllInternalPasswords这个编辑好的宏,执行,并且确定数次,就OK了。


猜你喜欢
- 我们都知道系统一般默认是administraor用户,怎么添加新用户?本文就为大家带来了详细的解决教程,需要的朋友一起看看吧Win11怎么添
- 在安装一些软件之后,我们的电脑总是会发生一点小变化,不是桌面上多了几个网址图标,就是IE浏览器的默认主页被篡改成乱七八糟的网址。在安装一些软
- 不少喜欢CSGO的小伙伴都是使用5E对战平台来玩游戏的,但是使用平台登录的时候难免会遇到CSGO掉帧的情况,那么遇到这种情况应该怎么办呢?下
- Win10如何打造个性化的Dock栏?Dock栏是iOS系统自带的一个任务显示及切换的快捷窗口,通过Dock栏我们可以迅速打开某些软件或文件
- 据有些朋友反应说,打开开始菜单,发现有设置这一功能,通过一番查找资料,原来是设置要在开始菜单上显示和不显示还有个控制开关,所以我们只需要找到
- 手机上的开发者选项是非常有用的,他可以大幅度的提升手机的性能,但是这个选项一般是隐藏的,今天就为大家带来了miui12开发者选项的开启方法,
- wps软件是一款集word、excel等热门办公软件强大功能于一体的办公软件,在wps软件中用户就可以享受到很多丰富的功能,这让用户在编辑文
- 当我们准备进行自己电脑的系统安装或重新安装时,有些小伙伴不知道具体该怎么做才好。关于如何安装蕃茄园win10系统这一问题,小编认为,首先我们
- 在Excel单元格中,我们常常输入文字的时候会发现如果不手动来换行的话,就会超出单元格的宽度,下面让小编为你带来如何设置excel自动换行的
- excel2016表格怎么添加图片题注列表?excel2016表格中可以使用SmartArt添加图片题注列表,该怎么添加呢?下面我们就来看看
- 微软今天在 Beta 频道 (.436) 中为大家提供了一个新的 Windows11 更新,并宣布将为 Beta 频道启动 Bug Bash
- windows media player是一款强大的本地视频播放器,很多小伙伴都会使用到它,不过最近就有小伙伴在使用的过程中碰到了一些问题,
- Word2007中如何使用或消除智能指针编程功能智能指针是Word中的一项编程功能,用户可以在Word2007中启用或取消智能指针功能,操作
- 喵影工厂怎么导入音乐?喵影工厂是一款多功能的视频编辑软件,我们在喵影工厂中制作视频的时候,如果想要导入音乐的话,要怎么进行操作呢?下面就给大
- Win7电脑显示器闪烁怎么办?有很多朋友遇到这个问题,本文就给小编带来Win7电脑显示器闪烁的原因及解决方法,希望可以帮助到大家Win7电脑
- 今天微软正式向广大用户推出Win11正式版,包括大家期待已久的正式版,还有一个Dev测试版。如果你想第一时间接收Windows系统更新通知,
- 用户在打开xbox商店后,进入自己要下载的软件、游戏,想看一下别的用户对软件、游戏的评价,但是发现看不到评论,那么接下来让我们一起看看xbo
- 如果你的电脑是Win7系统,但是你偶尔需要在win10系统上运行一些程序,那么你就可以借助虚拟机安装Win10系统,这样你的电脑中就有双系统
- INdesign怎么绘制虚线描边连接双箭头的效果?INdesign中想要绘制双箭头,该怎么绘制虚线连接双箭头的效果呢?下面我们就来看看详细的
- 我们在用Excel有的时候需要录入的内容很长,希望能够在同一个单元格内多行录入,可Excel的单元格不同于Word,既没有换行的命令,直接用