**

Excel文档被设置保护后忘记密码

**
Excel文档不知道谁给设置了保护,导致其他人无法在进行编辑。于是就上网查找方法,大多数都是xlsx修改为压缩包然后重新还原的,但是我的文档是xls的。这边就做个笔记,以防止以后找不到

第一步 点击视图,找到宏,选择录制宏,宏名可自行修改,然后点击确定


第二步 选择停止录制

第三步 选择查看宏

如图弹出这个选择编辑

第四步 在弹出的框里输入以下代码

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


如图加进去代码后点击右上角保存,或者Ctrl+S,然后关闭该页面

第五步 点击查看宏 选择执行

然后闭眼点确定即可

Excel文档被设置保护后忘记密码相关推荐

  1. MFC创建新Excel文档并设置其中的格式和字体

    MFC创建新Excel文档并设置其中的格式和字体 转载 生成Excel.obl对象类excel.h 创建对象 [cpp] view plaincopyprint? Range m_ExlRge;    ...

  2. 腾讯文档如何设置保护单元格与工作表?

    最近利用腾讯文档在线收集信息的时候发现有些信息比较隐私,为了设置成仅创作者可以查看,其他成员只能编辑自己的信息,而看不到其他成员的信息,腾讯文档在线表格支持保护某个范围的单元格或保护某个工作表,保护区 ...

  3. 两个excel文档查找相同选项后替换_看似普通的查找和替换功能,用好了,能让你的工作效率翻一番...

    关注[新精英充电站]能力提升看得见! 在Word中,查找和替换功能是编辑文档时时常要用到的重要功能,它能帮助我们快速将文档或表格中查找到的内容或格式等替换为指定的内容或格式,特别是遇到大量需要修改的相 ...

  4. MFC创建新Excel文档并设置其中的格式和字体+底纹(OLE/COM)

    原文链接:http://blog.sina.com.cn/s/blog_71265dc90101b523.html 生成Excel.obl对象类excel.h 创建对象 [cpp] viewplain ...

  5. Excel文档安全性设置

    1.防止其他用户在表格乱录入 2.限定只能填固定词 3.工作表保护:限制用户删除数据或者删除表中部分数据 3.1全部保护 步骤:直接在审阅选项卡中点击保护工作簿即可(可设置密码) 3.2部分保护 步骤 ...

  6. 计算机自定义大小修改数值,如何将电脑excel文档中的单元格颜色设置为根据数值大小自动修改...

    如何将电脑excel文档中的单元格颜色设置为根据数值大小自动修改 腾讯视频/爱奇艺/优酷/外卖 充值4折起 当我们在使用电脑的时候,如果想要处理数据的话,一般都会用到excel软件,在excel中,如 ...

  7. 文档文档被设置了保护密码的处理办法

    今天朋友的一个word文档不能编辑,查看一下,是设置了密码保护,最简单的办法,就是新建一个"空白文档",把原文档内容复制粘贴过来,这样就很简单的解决了,但是原有的宏和格式将丢失一些 ...

  8. 在线合并Excel文档的HTML网页工具

    构建一个在线合并Excel文档的HTML网页工具 导语: 在本篇技术分享文章中,我将向您展示如何使用HTML.CSS和JavaScript构建一个功能强大的在线合并Excel文档的网页工具.这个工具可 ...

  9. C#如何设置Excel文档保护——工作簿、工作表、单元格

    简介 Excel在工作和学习中应用广泛,是必不可少的数据统计与处理工具.对于一些重要的Excel文件,只供特殊人员查看.编辑或者防止重要数据对外泄露时,就需要设置文档保护,包括设置访问密码.设置文件只 ...

  10. EasyExcel 实现设置水印(只支持07版Excel文档)

    目录 1 Maven依赖 2 WaterMarkModel 3 CustomWaterMarkHandler 4 调试代码 5 调试结果 注: 1 Maven依赖 <!-- easyExcel ...

最新文章

  1. 蓝牙-HCI错误码列表
  2. SAP ABAP OLE 输出数据到 Excel 无法自动保存的解决
  3. 2017上海金马五校 购买装备 贪心+二分Check
  4. docker小实战和应用
  5. android实现3种定位的切换,Android 滑动定位+吸附悬停效果实现
  6. Spring Boot 是什么,有什么用。
  7. Android Input 子系统初探
  8. HTTP系列学习(笔记一):一文带你详解HTTP协议
  9. 如何在数字化转型战略中真正获得价值?浅谈数字化转型的四个层级
  10. 苹果挥刀,iPhone 12 mini要换处理器了,无缘A14!
  11. Div 在页面中居中
  12. php mysql敏感词_PHP敏感词处理
  13. [实战]200类鸟类细粒度图像分类
  14. 代码时间换空间以及空间换时间
  15. Real-Time Rendering——5.2.2 Punctual Lights精准光
  16. 美国心脏协会:六种心血管疾病的症状区别
  17. php cms下载地址,让PHPCMS下载内容页显示链接真实地址
  18. 精品文章!精讲光模块的方方面面,收藏!
  19. c语言编程顺序查找法,建立顺序表,实现顺序表的遍历,在顺序表中查找关键字为e的元素(c语言编写)...
  20. 视频点播服务器的配置如何选择,需要多大的带宽

热门文章

  1. PyQt5整合Scrapy和matplotlib实现可视化爬虫by墨阳剑(三)
  2. 报错Pointcut is not well-formed: expecting ‘(‘ at character position 9(已解决)
  3. 浅谈Keil-MDK创建项目编译过程---Code-data,RO-data,RW-data,ZI-data
  4. linux eclipse adt下载,Eclipse搭建Android开发环境图文教程(eclipse+ADT插件+AndroidSDK)文档类...
  5. linux上查看日志文件技巧,tial、cat、wc,sed详解(文件大小、行数、查看指定行)
  6. 互联网医疗领域月度观察——数字乡村建设加快,“互联网+医疗健康”带动乡村高质量发展
  7. 大数据平台三大优势详解-行云管家
  8. 多手柄输入(20150515、20150610、20150827)
  9. 关于window10系统 IE浏览器 双击没反应 打不开 无法安装问题
  10. java哥德巴赫猜想实验报告_Java实现哥德巴赫猜想并优化