[英]What are the differences between the microsoft excel security notice popup and the message bar in excel 2013?
我在 excel 工作簿中开发 VBA 功能时遇到问题。 此工作簿适合没有管理权限的最终用户使用,他们需要激活此特定工作簿上的宏才能使用它。
为此,我做了以下工作:
这可以:
' Code to hide temporary ws and show target ws
Private Sub setTargetVisibility()
Dim ws As Excel.Worksheet
ThisWorkbook.Activate
Set ws = ThisWorkbook.Sheets(getParm("tempHomeWSName"))
With ws
.Visible = xlSheetVeryHidden
End With
Set ws = ThisWorkbook.Sheets(getParm("homeWSName"))
With ws
.Visible = xlSheetVisible
.Activate
End With
End Sub
这在大多数情况下都可以正常工作,因为系统会提示用户通过消息栏激活宏:
但是,他们有时会收到另一个提示来激活宏:microsoft excel 安全通知弹出窗口。 每当他们通过此弹出窗口激活宏时,他们会在带有上述代码的子程序中收到运行时错误 1004(例如 _workbook object 的方法激活失败)。
编辑:需要注意的重要一点是,这个 excel 文件在受保护的视图中打开,因为它是由 web 应用程序生成并由用户在使用前下载的。
是什么导致在 excel 2013(消息栏与弹出窗口)中启用宏的这些不同方式? 它们之间的行为差异是什么?
提前致谢。
问候,
默认情况下,当您第一次打开启用宏的工作簿时,您会在功能区下方看到一个黄色的“安全警告”栏。 单击“启用内容”按钮将启用宏。
如果在您使用宏打开文件时 Visual Basic 编辑器处于打开状态,则会显示 Microsoft Excel 安全通知。
正如@David Donayo 在接受的答案中提到的那样,触发 Microsoft Excel 安全通知弹出窗口与消息栏警告的原因是 VBA 编辑器已经为另一个 xlsm 文件打开。
What caused my issue (runtime error 1004 when trying to make Object Model calls such as Application.Calculate or ThisWorkbook.Activate at WorkbookOpen event) is that the issue described here ( https://support.microsoft.com/en-us/help /2745652/object-model-calls-may-fail-from-workbookopen-event-when-exiting-prote ) 仍然存在于 excel 2013 中,当退出受保护的视图然后通过 Microsoft ZC1D81AF5835844B4E9D936910DEDF 激活宏时。
当退出受保护的视图并通过消息栏警告激活宏时,不会出现此问题。
I did not implement the workaround described in the link above (defer Object Model calls from the WorkbookOpen event to the WorkbookActivate event if the workbook is opened in Protected view) as in my context end users should not have the VBA editor open. 因此,我无法判断这种解决方法是否有效,但看不出它为什么不应该的原因。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.