设置VBA编码保护
设置VBA编码保护
诗的起源
Sub SetProtect()
  Dim FileName As String
胡歌主演的电视剧  FileName = Application.GetOpenFilename("Excel文件(*.xls & *.xla),*.xls;*.xla", , "VBA破解")
  If FileName = CStr(False) Then
    Exit Sub
  Else
    VBAPassword FileName, True
  End If
cad批量打印
End Sub
Private Function VBAPassword(FileName As String, Optional Protect As Boolean = False)
    If Dir(FileName) = "" Then
      Exit Function
    Else
      FileCopy FileName, FileName & ".bak"
    End If
    Dim GetData As String * 5
    Open FileName For Binary As #1
    Dim CMGs As Long
    Dim DPBo As Long
    For i = 1 To LOF(1)
        Get #1, i, GetData
        If GetData = "CMG=""" Then CMGs = i
        If GetData = "[Host" Then DPBo = i - 2: Exit For
    Next
   
    If CMGs = 0 Then
      MsgBox "请先对VBA编码设置一个保护密码...", 32, "提示"
      Exit Function
    End If
   
    If Protect = False Then
      Dim St As String * 2
      Dim s20 As String * 1
       
      '取得一个0D0A十六进制字串
      Get #1, CMGs - 2, St
   
      '取得一个20十六制字串
      Get #1, DPBo + 16, s20
   
      '替换加密部份机码
      For i = CMGs To DPBo Step 2
          Put #1, i, St
      Next
       
      '加入不配对符号
      If (DPBo - CMGs) Mod 2 <> 0 Then
          Put #1, DPBo + 1, s20
      End If
      MsgBox "文件解密成功......", 32, "提示"
假设检验的步骤    Else
      Dim MMs As String * 5
      MMs = "DPB="""
      Put #1, CMGs, MMs
      MsgBox "对文件特殊加密成功......", 32, "提示"
    End If
    Close #1
wuxiaxiaoshuoEnd Function
'移除VBA编码保护
Sub MoveProtect()
Dim FileName As String
FileName = Application.GetOpenFilename("Excel文件(*.xls & *.xla),*.xls;*.xla", , "VBA破解")
If FileName = CStr(False) Then
Exit Sub
Else工商银行账号
VBAPassword FileName, False
End If
End Sub
'设置VBA编码保护
Sub SetProtect()
Dim FileName As String
FileName = Application.GetOpenFilename("Excel文件(*.xls & *.xla),*.xls;*.xla", , "VBA破解")
If FileName = CStr(False) Then
Exit Sub
Else
VBAPassword FileName, True
End If
End Sub
Private Function VBAPassword(FileName As String, Optional Protect As Boolean = False)
If Dir(FileName) = "" Then
Exit Function
Else
FileCopy FileName, FileName & ".bak"
End If
Dim GetData As String * 5
Open FileName For Binary As #1
Dim CMGs As Long
Dim DPBo As Long
For i = 1 To LOF(1)
Get #1, i, GetData
If GetData = "CMG=""" Then CMGs = i
If GetData = "[Host" Then DPBo = i - 2: Exit For
Next
If CMGs = 0 Then
MsgBox "请先对VBA编码设置一个保护密码...", 32, "提示"
Exit Function
End If
If Protect = False Then
Dim St As String * 2
Dim s20 As String * 1
'取得一个0D0A十六进制字串
Get #1, CMGs - 2, St
'取得一个20十六制字串
Get #1, DPBo + 16, s20
'替换加密部份机码
For i = CMGs To DPBo Step 2
Put #1, i, St
Next
'加入不配对符号
If (DPBo - CMGs) Mod 2 <> 0 Then
Put #1, DPBo + 1, s20
End If
MsgBox "文件解密成功......", 32, "提示"
Else
Dim MMs As String * 5
MMs = "DPB="""
Put #1, CMGs, MMs
MsgBox "对文件特殊加密成功......", 32, "提示"
End If
Close #1
End Function
Sub PasswordBreaker()
  Dim i As Integer, j As Integer, k As Integer
  Dim l As Integer, m As Integer, n As Integer
  Dim i1 As Integer, i2 As Integer, i3 As Integer
  Dim i4 As Integer, i5 As Integer, i6 As Integer
  On Error Resume Next
  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
  ActiveSheet.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 ActiveSheet.ProtectContents = False Then
  MsgBox "One usable password is " & Chr(i) & Chr(j) & _
  Chr(k) & Chr(l) & Chr(m) & Chr(i1) & Chr(i2) & _
  Chr(i3) & Chr(i4) & Chr(i5) & Chr(i6) & Chr(n)
  ActiveWorkbook.Sheets(1).Select
  Range("a1").FormulaR1C1 = Chr(i) & Chr(j) & _
  Chr(k) & Chr(l) & Chr(m) & Chr(i1) & Chr(i2) & _
  Chr(i3) & Chr(i4) & Chr(i5) & Chr(i6) & Chr(n)
  Exit Sub
  End If
  Next: Next: Next: Next: Next: Next
  Next: Next: Next: Next: Next: Next
  End Sub
怎样防止别人取消自己隐藏的Excel工作表
Excel中,通常隐藏工作表的操作方法如下:
  把需要隐藏的工作表激活成当前工作表,执行一下格式工作表隐藏命令,即可将其隐藏起来。
  这样隐藏的工作表,通过执行格式工作表取消隐藏命令,打开取消隐藏对话框(如图1),选中需要显示出来的工作表名称,单击一下确定按钮即可将其显示出来。
  今天,我给大家介绍一种隐藏工作表的方法,通过这种方法隐藏的工作表,别人显示不出来。
  1、启动Excel,打开相应的工作簿文档。
  2、按下Alt+F11组合键进入VBA编辑状态(如图2)
  3、按下F4功能键,展开属性窗口(参见图3)
  4、选中相应工作簿中需要隐藏的工作表(“Sheet3(PPT)”),然后在下面的属性窗口中,到“Visible”选项,单击其右侧的下拉按钮,在随后出现的下拉列表中,选择 “0-xlSheetVeryHidden”选项。
  注意:每个工作簿文档中,至少要有一个工作表不被隐藏。
  5、再执行工具→VBAProject属性命令,打开“VBAProject-工程属性对话框(如图3)
  6、切换到保护标签下,选中查看时锁定工程选项,并输入密码,确定返回(参见图3)
  7、退出VBA编辑状态,保存一下工作簿文档,隐藏实现。
  经过这样的设置以后,我们发现格式工作表取消隐藏命令是灰的,无法执行;如果想通过VBA编辑窗口修改属性,发现需要提供密码(如图4),不知道密码就无法取消隐藏了。

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。