我创建了一个包含大约5页vba代码的Excel文件。一切都很好,直到我选择为工作簿创建一个宏来保护它。像。的东西。
Dim pass as string/
if pass <> "PAR> or pass<>"par" then activeworkbook.close.
我认为OR
会让事情变得混乱。现在我无法访问我的工作簿。无论我介绍什么,它都会关闭工作簿。我在这里可以提一下,pass是一个输入框。
有人可以帮助我解决这个问题。我失去了我的全部工作。
LE:我做到了!感谢您的支持! :)
答案 0 :(得分:2)
尝试这种方式:
Sub main()
Dim secAutomation As MsoAutomationSecurity
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Remember the macro security settings and disable macros in target workbook. '
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
secAutomation = Application.AutomationSecurity
Application.AutomationSecurity = msoAutomationSecurityForceDisable
Workbooks.Open "<path to your workbook>"
''''''''''''''''''''''''''''''''''''''''''''''
'Reinstate previous macro security settings. '
''''''''''''''''''''''''''''''''''''''''''''''
Application.AutomationSecurity = secAutomation
End Sub
或手动将宏设置更改为“禁用所有带通知的宏”
答案 1 :(得分:0)
打开任何其他工作簿并进入VBA IDE(ALT + F11)
在立即窗口中输入
application.EnableEvents=False
然后你就可以打开你不可能的&#34;工作簿
只要您在立即窗口中需要返回常规类型
application.EnableEvents=True
答案 2 :(得分:0)
尝试打开另一个工作簿,然后使用statement application.enableEvents = false
然后关闭此工作簿,打开您希望的工作簿