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 |