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 " & vbCrLf & vbCrLf & "BeyondPC" & vbCrLf & "http://blog.sina.com.cn/beyondpc" 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
|
相关推荐
在Excel VBA编程中,有时候我们需要批量处理工作簿中的多个工作表,比如将它们分别保存为独立的工作簿。"另存所有工作表为工作簿VBA"这个标题所描述的功能,就是通过编写VBA宏来实现这样的自动化操作。这不仅可以...
### EXcelVBA另存工作簿之后删除按钮及宏代码 #### 一、知识点概述 在Excel VBA中,可以通过编写宏代码实现多种自动化任务,包括但不限于数据处理、格式化设置以及文件操作等。本篇内容主要介绍了如何利用VBA实现...
VBA(Visual Basic for Applications)是Excel内置的一种编程语言,它允许我们创建自定义宏和功能,以自动化复杂的任务,如拆分工作簿和工作表。针对给定的标题和描述,我们将探讨如何使用VBA来实现按列拆分工作簿,...
### Excel—“撤销工作表保护密码”的破解并获取原始密码 #### 概述 在Excel中,用户可以为工作表设置密码以保护敏感数据或防止未经授权的修改。然而,在某些情况下,用户可能需要移除这些密码保护,比如当忘记了...
在Excel中,VBA(Visual Basic for Applications)是一种强大的编程工具,允许用户自定义工作簿、工作表和宏的行为。然而,有时我们可能会遇到带有密码保护的VBA项目,这可能阻碍了对代码的查看或编辑。本篇文章将...
在Excel VBA编程中,有时候我们需要对大型工作簿进行管理和优化,这可能涉及到将一个大文件拆分成多个小文件,每个文件对应原工作簿中的一个单独工作表。这个任务可以通过编写VBA宏来实现,从而自动化整个过程。下面...
VBA(Visual Basic for Applications)是Microsoft Office套件中用于自动化和自定义应用程序的强大工具,尤其在Excel中,VBA可以编写代码来控制工作簿和工作表的各种操作。以下是对标题和描述中所述知识点的详细解释...
### EXCEL工作表保护密码破解方法详解 在日常工作中,我们常常会遇到Excel工作表被设置保护密码的情况,有时候甚至可能会忘记自己所设置的密码。本文将详细介绍一种实用的方法来帮助用户解决这个问题。 #### 一、...
### VBA中判断工作簿是否结构、窗口保护 在日常工作中,我们经常需要处理各种Excel文件,有时还需要向这些文件中添加新的工作表(sheet)来显示数据处理的结果。然而,如果遇到那些设置了结构保护或窗口保护的工作簿...
EXCEL工作表保护密码破解方法是使用VBA宏来录制和编辑宏,从而破解工作表和工作簿结构的密码。该方法使用了VBA宏来录制一个空宏,然后编辑宏的内容,替换为破解密码的代码。 二、录制宏 录制宏是使用VBA宏来录制一...
### EXCEL工作表保护密码破解方法 #### 一、引言 在日常工作中,我们经常使用Excel进行数据处理和分析。有时候,为了保护敏感信息不被未经授权的人篡改,我们会设置工作表保护密码。但是一旦忘记了这个密码,就可能...
EXCEL工作表保护密码破解 本文档主要介绍了如何破解EXCEL工作表的保护密码,使用了VBA宏来实现密码破解。下面是相关知识点的详细解释: 1.EXCEL工作表保护密码的破解方法: 在EXCEL中,有多种方式可以保护工作表...
本文介绍了如何使用VBA宏来去除Excel工作表和工作簿的密码保护,这种方法对于忘记密码或需要紧急访问受保护文件的情况非常有用。但是,在执行此类操作时,用户必须充分意识到可能存在的安全风险,并采取适当的预防...
### Excel自动拆分工作簿中的多个工作表为文件 #### 概述 在日常工作中,我们经常需要处理大量的Excel数据。有时,一个工作簿中包含了多个工作表,而我们需要将这些工作表分别保存为独立的文件。手动进行这项操作...
标题中的“Excel VBA: 工作表(Sheet)浏览导航插件”指的是一个使用Excel VBA(Visual Basic for Applications)编程语言开发的工具,它为Excel用户提供了更方便的工作表浏览和导航功能。VBA是Microsoft Office应用...
在这里,你可以创建模块、类模块和工作簿/工作表事件。 2. **模块**:VBA代码通常储存在模块中,包括标准模块和类模块。标准模块用于存放通用函数和过程,而类模块则用于创建自定义对象。 3. **对象模型**:Excel ...
在Excel中,有时为了保护VBA宏代码不被他人查看或修改,我们通常会为工作簿设置VBA项目密码。然而,如果忘记密码或者需要在没有密码的情况下访问VBA代码,这可能会成为一个问题。本教程将详细介绍如何使用VBA宏来...
excel宏工具VBA工具,合并多个excel文件 合并多个excel工作表excel宏工具VBA工具合并excel合并多个工作簿工作表
首先,确保你对Excel VBA有一定的基础了解,包括工作簿(Workbook)、工作表(Worksheet)、范围(Range)等基本概念。VBA是Excel内置的一种编程语言,能够帮助我们编写自定义函数和宏,实现对Excel对象的操作。 **...
- `Protect`:保护工作表免受某些编辑。 3. **Workbook对象的属性**: - `Name`:获取或设置工作簿的文件名。 - `Path`:获取工作簿的路径。 - `ActiveSheet`:获取当前活动的工作表。 - `Sheets.Count`:返回...