excel2010取消保护忘记密码宏的方式-针对公务员职位表保护

2023-05-16

excel2010

视图-宏-新建-取消新建-编辑-替换以下内容

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


本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

excel2010取消保护忘记密码宏的方式-针对公务员职位表保护 的相关文章

随机推荐

  • NoSuchMethodError、NoClassDefFoundError的常见原因和通用解决方式

    目录 环境信息 问题描述 错误分析 解决方法 常见原因 1 第三方包 xff0c 作用域不对导致应用没导入该包 2 编译时和运行时使用的版本不一样 3 JDK版本不一样 4 多个同路径 同名的类 1 代码复制场景 2 代码移动场景 排查步骤
  • Spring Cloud Gateway从注册中心自动注册配置路由信息

    环境信息 Spring Boot xff1a 2 0 8 RELEASE Spring Boot内置的tomcat xff1a tomcat embed core 8 5 37 Spring Cloud Gateway xff1a 2 0
  • CORS过滤器优先级不对,预检请求正常,正式请求报错CORS跨域

    环境信息 Spring Boot xff1a 2 0 8 RELEASE Spring Boot内置的tomcat xff1a tomcat embed core 8 5 37 问题描述 在使用浏览器访问应用 xff0c 给服务端发送请求的
  • 利用shell设置每隔三天运行一次sql文件

    文章目录 前言一 main sh二 assist sh三 定时四 直接上代码 前言 我从网络上查了老半天 xff0c 全都是每隔几天运行一次 xff0c 但是在第二月一日便会重置 xff0c 例如1月31日运行了 xff0c 2月1日又运行
  • php使用curl访问https示例分享

    curl是利用URL语法在命令行方式下工作的开源文件传输工具 下面介绍一下php使用curl访问https的示例 大家参考使用吧 为方便说明 xff0c 先上代码吧 复制代码 代码如下 curl POST 64 param string u
  • Ajax实现省份-城市二级下拉联动

    基于XML xff0c 以POST方式 xff0c 完成省份 城市二级下拉联动 数据库 mysql xff0c 表 xff1a t city JavaWeb项目 xff0c 使用servlet ajax js 创建AJAX异步对象 func
  • weblogic10.3配置自定义的DB2驱动

    文章主要内容 xff1a 在windows操作系统中 xff0c 使用weblogic10 3服务器 xff0c 使用com ibm db2 jcc DB2Driver驱动来配置db2数据源 在使用weblogic自带的db2驱动weblo
  • websphere缓存

    使用was服务器 xff0c 当出现改了web xml 修改了java文件 加了或改了jar包 添加了依赖包 改了jsp文件等不生效的时候 xff0c 有可能就是因为was的缓存造成的 was缓存路径有多个 xff1a opt IBM We
  • nohup命令

    在应用Unix Linux时 xff0c 我们一般想让某个程序在后台运行 xff0c 于是我们将常会用 amp 在程序结尾来让程序自动运行 比如我们要运行mysql在后台 xff1a usr local mysql bin mysqld s
  • Lucene5中的Directory

    Directory即Lucene中对索引目录的一个抽象 xff0c 体现到API上 xff0c 它被设计为一个抽象类 xff0c 类里面定义了一些抽象方法 xff0c 如listAll列出目录下所有文件 xff0c deleteFile S
  • linux运行多个tomcat

    在一个linux服务器上需要运行多个tomcat xff0c 需要做一些配置 xff0c 不然除了端口会冲突 xff0c 执行其中一个tomcat的bin目录下的startup sh和shutdown sh会有同时启动 停止2个tomcat
  • JDBC连接获取到ResultSet后自动封装到JavaBean

    利用反射机制从ResultSet自动绑定到JavaBean xff1a 要求 xff1a JavaBean的字段和ResultSet的字段名或 别名 一样 xff08 不区分大小写 xff09 注意 xff1a 如果JavaBean的字段和
  • composite-id class must implement Serializable

    org hibernate MappingException composite id class must implement Serializable com xxx pojo Organization 这一段中 xff0c 最重要的错
  • navicat如何修改字体大小颜色

    友情链接 xff1a http xiqingchun com forum php navicat作为很多数据库的可视化管理界面确实是比较好用的 xff0c 有时候我们需要修改navicat的显示界面的字体大小样式颜色等等 xff0c 这时候
  • python3调用7-zip解密解压压缩包(hmac加密)

    文章目录 一 调用7z exe二 获取压缩包路径及其名字三 按照hmac加密方式进行解密四 设置将解压出的文件放入的目录五 最后将各变量整合到一起 xff0c 组成解压缩命令 xff0c 传到popen xff08 xff09 函数内六 完
  • Ubuntu相对路径和绝对路径

    ubuntu绝对路径 xff1a 例如在目录 home lzj temp下有一个文件filename txt那么filename txt文件的绝对路径就是 home lzj temp ubuntu相对路径 xff1a 如果你当前路径是在 h
  • ubuntu把终端信息输出到文本文件中的方法

    ubuntu把终端信息输出到文本文件中的方法 方法一 xff1a 把终端中所有信息都写到文本文件中 在终端的命令行中输入以下命令 xff1a script f output txt 这样就会在当前目录下创建一个output txt文件 接下
  • ubuntu配置有线网络笔记

    ubuntu配置有线网络笔记 1 用命令ifconfig查看网络信息 eth0 xff0c eth1 xff0c eth2 代表网卡一 xff0c 网卡二 xff0c 网卡三 lo代表127 0 0 1 xff0c 即localhost 2
  • syntax error: unexpected end of file解决方法

    syntax error unexpected end of file解决方法 在windows环境下编辑的脚本通过Xftp上传到linux系统执行的时候会提示syntax error unexpected end of file xff0
  • excel2010取消保护忘记密码宏的方式-针对公务员职位表保护

    excel2010 视图 宏 新建 取消新建 编辑 替换以下内容 Option Explicit Public Sub AllInternalPasswords 39 Breaks worksheet and workbook struct