在我们公司内部,我们有2个在Excel中不相处的插件。其中一个插件来自SAP(例如无法修改)。另一个是使用Add In Express
开发的本地版本问题仅限于Excel。当我们尝试从受保护的视图中提取文档时。使用以下代码
ExcelApp.ActiveProtectedViewWindow.Edit()
当我们执行该行代码时,另一个(SAP)插件会开始抛出访问冲突。
1st error: Attempted to read or write protected memory. This is often an indication that other memory is corrupt
2nd error: Exception from HResult 0x800A03EC
现在我正试图修复冲突。但我被卡住了。 我找不到另一种方法来成功地将文档从受保护的视图中提升
暂时禁用SAP addIn似乎也不起作用。因为Application.Addins不包含COM-Addins。 Application.CommAddins会引发以下错误:
ExcelApp.COMAddIns The embedded interop type 'COMAddIns' does not contain a
definition for'Microsoft.Office.Interop.Excel._Application' since it was not used
in the compiled assembly. Consider casting to object or changing the 'Embed Interop Types'
property to true.
然而Embed Interop Types
设为真。
所有人都有想法吗?
注意
禁用Protected view
不是一种选择。由于它是在公司层面决定的: - (
答案 0 :(得分:0)
我设法解决了这个问题。感谢Charles Williams 使用以下代码我可以使用vb.code
禁用/启用某些COM-Addins在这种情况下,SapExcelAddIn
是AddIn,它会导致我们遇到的所有问题。
For Each certAddin As Object In ExcelApp.COMAddIns
log("progId:" & certAddin.progId) 'Logging the id of all Com-addins
If (certAddin.progId.Equals("SapExcelAddIn")) Then
log("disconnecting:" & certAddin.progId)
certAddin.Connect = False
End If
Next