Excel“取消工作表保护”忘记密码并恢复原始密码

news2024/9/19 22:10:45

文章目录

  • 1.前言
  • 2.破解步骤
  • 3. 最终效果
  • 4.参考文献

1.前言

有时候别人发来的Excel中有些表格不能编辑,提示如下,但是又不知道原始密码
在这里插入图片描述

2.破解步骤

1、打开您需要破解保护密码的Excel文件;

2、依次点击菜单栏上的视图—宏----录制宏,输入宏名字如:test;

在这里插入图片描述
在这里插入图片描述

3、停止录制(这样得到一个空宏);

4、依次点击菜单栏上的工具—宏----宏,选test,点编辑按钮;

在这里插入图片描述
在这里插入图片描述

5、删除窗口中的所有字符(只有几个),替换为下面的内容,并保存;

在这里插入图片描述
替换内容见下:

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

6、保存后,关闭编辑窗口;

在这里插入图片描述

7、依次点击菜单栏上的视图—宏-----宏,选AllInternalPasswords,点击“执行”按钮;

在这里插入图片描述

8.一直点击“确定”,然后等待,中间可能会有程序无响应的情况,不用理会,耐心多等待一会儿。

在这里插入图片描述
在这里插入图片描述

9.然后就可以得到破解后的密码啦,且会自动取消Excel文档的工作表保护,直接保存文件就可以

在这里插入图片描述
在这里插入图片描述

3. 最终效果

表格可以编辑了。
在这里插入图片描述

在这里插入图片描述

4.参考文献

https://blog.csdn.net/xujiangdong1992/article/details/76549062

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2056020.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Spring Boot内嵌Tomcat处理请求的链接数和线程数

Spring Boot内嵌Tomcat处理请求的连接数和线程数 处理请求的连接数和线程数配置 Spring Boot的配置项 #等待连接数 server.tomcat.accept-count100 #最大链连接数 server.tomcat.max-connections8192#最小备用线程数 server.tomcat.threads.min-spare10 #最大工作线程数 ser…

【git命令相关】git上传和删除文件步骤

(一)git登录 1. git bash窗口输入 git config --global user.name "你的Git账号" git config --global user. Email "你的Git邮箱"2. 生成密钥 ssh-keygen -t rsa -C "你的Git邮箱"在此命令执行的返回结果中找到key存放…

海康VisionMaster使用学习笔记11-VisionMaster基本操作

VisionMaster基本操作 VM示例方案 1. 工具拖拽及使用方式 分别从采集和定位栏里拖拽图像源,快速匹配,Blob分析工具 2. 模块连线 依次连线 3.如何订阅 点击快速匹配,可以看到输入源已订阅了图像1的图像,Blob分析类似 4. 方案操作及全局触发 点击快速匹配,创建特征模版,框选…

vue-cli搭建过程,elementUI搭建使用过程

vue-cli vue-cli 官方提供的一个脚手架,用于快速生成一个 vue 的项目模板;预先定义 好的目录结构及基础代码,就好比咱们在创建 Maven 项目时可以选择创建一个 骨架项目,这个骨架项目就是脚手架,我们的开发更加的快速。…

深兰科技荣获CFS第十三届财经峰会“2024杰出出海品牌引领奖”

近日,以“向新而行,新质生产力激发新活力”为主题的“CFS2024第十三届财经峰会暨Amazing 2024创新企业家节”在北京隆重开幕。峰会揭晓了第十三届“CFS 2024企业奖”的评选结果,深兰科技凭借自身在AI机器人出口和海外市场开拓等品牌全球化方面…

60KW~180KW一体式充电桩电路方案!

本次小编给大家带来了一款60KW~180KW的一体式充电桩电路方案,本方案包含接线图,电路原理图,PCB图,BOM,协议说明,产品标准等资料! 下载链接!https://t.1yb.co/KW1R 本方案采用STM32F…

std::wcout,std::cout控制台输出中文乱码,std::cerr字符串的字符无效

系列文章目录 文章目录 系列文章目录前言一、中文乱码原因二、解决方法1.如果是windos11下,使用英文语言,需要加以下代码2.如果是中文语言只需要一行关键代码3.如果在异常处理中显示宽字符中文4.完整代码如下:实现文件测试代码输出打印 前言 …

【图像特效系列】图像毛玻璃特效的实践 | 包含代码和效果图

目录 一 毛玻璃特效 1 代码 2 效果图 图像特效系列主要是对输入的图像进行处理,生成指定特效效果的图片。图像素描特效会将图像的边界都凸显出来;图像怀旧特效是指图像经历岁月的昏暗效果;图像光照特效是指图像存在一个类似于灯光的光晕特效,图像像素值围绕光照中心点呈…

极光推送(JPush)携手中大英才,打造智慧教育新模式

随着互联网技术的快速发展,在线教育行业蓬勃兴起,用户对学习体验的要求也越来越高。作为国内领先的职业技能知识培训服务商,中大英才(北京)网络教育科技有限公司(简称“中大英才”)始终致力于为多层次求知学习人士提供专业化、智能化和科学化…

实战演练:通过API获取商品详情并展示

实战演练:通过API获取商品详情并展示,通常涉及以下几个步骤:确定API接口、发送HTTP请求、处理响应数据、以及将数据展示给用户。这里我们以一个假想的商品详情API为例,使用Python语言和requests库来完成这个任务。 步骤 1: 确定A…

DMHS数据同步工具

DMHS数据同步工具 ​ 本章节主要介绍DM数据同步工具DMHS的使用,通过将oracle11g的数据同步到DM8的过程来理解DMHS的功能和作用。 安装前的准备 端口、服务信息 IP地址服务名称版本端口安装路径192.168.19.136OracleOracle11.0.21521/opt/oracle/DMHS源端dmhs_V3…

第100+22步 ChatGPT学习:概率校准 Platt Scaling

基于Python 3.9版本演示 一、写在前面 最近看了一篇在Lancet子刊《eClinicalMedicine》上发表的机器学习分类的文章:《Development of a novel dementia risk prediction model in the general population: A large, longitudinal, population-based machine-learn…

MapBox Android版开发 1 配置

MapBox Android版开发 1 配置 前言MapBox V9 配置创建工程配置地图配置私钥配置公钥配置仓库配置依赖配置权限地图初始化 显示地图布局文件地图Activity 运行效果 MapBox V11 配置创建工程配置地图配置私钥配置公钥配置仓库配置依赖配置权限 显示地图布局文件 运行效果 前言 本…

ee trade:黄金投资与股票投资的区别

黄金和股票, 是金融市场中两种常见的投资工具, 它们拥有截然不同的特点和风险, 了解它们的差异, 可以帮助投资者制定更合理的投资策略。 一、 投资性质: 避险与成长, 两种投资方向 黄金: 被视…

金价徘徊高位,市场聚焦美联储降息预期

现货黄金高位震荡 周二亚市早盘,现货黄金在2500美元/盎司关口附近徘徊,交投于2503.23美元/盎司附近。金价周一在创纪录的高位后出现回调,投资者从涨势中获利了结,并根据美联储的线索调整仓位,现货黄金最终收报2504.1…

Vue - 详细介绍 vue-monoplasty-slide-verify vue3-puzzle-vcode 滑动验证组件

Vue - 详细介绍 vue-monoplasty-slide-verify & vue3-puzzle-vcode 滑动验证组件 在日常的账号登录所需要的大部分是滑动验证来检验人为操作,免于字母验证码的繁琐输入,下面介绍在Vue2和Vue3中适用的滑动验证组件。 1、vue-monoplasty-slide-verif…

【GitLab】使用 Docker 安装 3:gitlab-ce:17.3.0-ce.0 配置

参考阿里云的教程docker的重启 sudo systemctl daemon-reload sudo systemctl restart docker配置 –publish 8443:443 --publish 8084:80 --publish 22:22 sudo docker ps -a 當容器狀態為healthy時,說明GitLab容器已經正常啟動。 root@k8s-master-pfsrv:~

远离内卷,新的跨境电商蓝海,智能小家电沃尔玛1P新赛道——WAYLI威利跨境助力商家

随着全球经济格局的变迁,跨境电商已经成为新的蓝海领域,其中智能小家电市场更是呈现出蓬勃的发展态势。在这样的背景下,沃尔玛1P会员凭借其独特的优势,正开辟出一条全新的跨境电商赛道。 一、智能小家电市场崛起,源于消…

通义灵码代码搜索功能的前沿性研究论文被软件工程国际顶会 FSE 录用

在今年 FSE 2024 软件工程大会上,阿里云通义灵码团队和重庆大学合作的论文《An Empirical Study of Code Search in Intelligent Coding Assistant: Perceptions, Expectations, and Directions》被 FSE Industry 2024 (CCF A) 录用。 本篇论文主要探讨了在智能编码…

告别硬件!试试ToDesk云电脑,让你的云端体验更有趣

在这个不断进步的数字时代,科技的每一次突破都在重新塑造我们的生活和工作模式。随着云计算技术的不断成熟,传统的硬件限制正在逐渐消失,一个全新的云端时代正悄然兴起。ToDesk云电脑作为这场变革的领航者,正引领我们进入一个更加…