是的, 加密有設定.
如何不讓VBE的環境, 可以進入.
google查到的方法, 試不出來.
如下請參考.
'// Run DisableGettingIntoVBE from a Event procedure
'// eg. Workbook_Open or Worksheet_Activate
'// THEN run EnableGettingIntoVBE from the Opp Event procedure
'// eg. Workbook_Close or Worksheet_Deactivate
Sub DisableVBE()
Application.VBE.MainWindow.Visible = False '// Close ALL windows 1st!
CmdControl 1695, False '// Visual basics Editor
CmdControl 186, False '// Macros...
CmdControl 184, False '// Record New Macro...
CmdControl 1561, False '// View Code
CmdControl 1605, False '// Design Mode
Application.OnDoubleClick = "Dummy"
CommandBars("ToolBar List").Enabled = False
Application.OnKey "%{F11}", "Dummy"
End Sub
Sub EnableVBE()
CmdControl 1695, True '// Visual basics Editor
CmdControl 186, True '// Macros...
CmdControl 184, True '// Record New Macro...
CmdControl 1561, True '// View Code
CmdControl 1605, True '// Design Mode
Application.OnDoubleClick = ""
CommandBars("ToolBar List").Enabled = True
Application.OnKey "%{F11}", ""
End Sub
Sub CmdControl(Id As Integer, TF As Boolean)
Dim CBar As CommandBar
Dim C As CommandBarControl
On Error Resume Next
For Each CBar In Application.CommandBars
Set C = CBar.FindControl(Id:=Id, recursive:=True)
If Not C Is Nothing Then C.Enabled = TF
Next
End Sub
Sub Dummy()
'// NoGo, leave blank OR Display a message eg.
'MsgBox "Sorry you this command is NOT available", vbCritical
End Sub作者: GBKEE 時間: 2014-11-13 14:25