COM加载项和VBA密码提示错误 [英] COM Add-ins and VBA password prompt bug

查看:93
本文介绍了COM加载项和VBA密码提示错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我所工作的公司正在使用部分基于COM的新版VBA插件替换旧版VBA插件。 当两个加载项同时安装时,我们遇到了一个错误。 

The company I work for is replacing a legacy VBA add-in with a new one that is partly COM based.  We have come across a bug when both add-ins are installed at the same time. 

Excel 2010和Excel 2013都出现了这个错误(可能是早期版本,但我还没有测试过)。

The bug occurs in both Excel 2010 and Excel 2013 (probably earlier versions too, but I haven't tested).

当您打开使用VBA加载项的工作簿然后关闭Excel时,系统会多次提示用户输入VBAProject密码,并且用户必须在Excel关闭之前取消每个对话框。

When you open a workbook that uses the VBA add-in and then close excel the user is prompted for the VBAProject password several times and the user must cancel each of these dialogs before Excel will close.

我在各种支持论坛上发现了几个描述相同错误的主题。 但是,我找到的论坛帖子都没有多大帮助。 至关重要的是,我们可以同时使用我们的加载项,并且我发现的唯一解决方案是
到目前为止是禁用触发错误的COM插件,或者删除VBA代码上的密码保护。  ;这些选项都不适合我们。

I have found several threads on various support forums that describe the same bug.  However, none of the forum threads I've found are of much help.  It is essential that we can use both our add-ins simultaneously and the only resolution I've found so far is to disable the COM addin that is triggering the bug, or to remove password protection on your VBA code.  Neither of those options is acceptable for us.

我们已经设法使用非常简单的VBA和COM插件重现错误,如下所示:

We have managed to reproduce the bug with very simple VBA and COM addins as follows:

VBA Addin只显示一个"Hello World"。 Workbook_Open事件中的用户表单。 此表单上有一个关闭按钮,可以卸载表单。  VBA代码必须受密码保护:

The VBA Addin just shows a "Hello World" user form in the Workbook_Open event.  this form has a close button on it that unloads the form.  The VBA code must be password protected:

Private Sub Workbook_Open()    
UserForm1.Show
End Sub


Private Sub CommandButton1_Click()
Unload UserForm1
End Sub

COM Addin是用c#编写的。它只是将一个处理程序附加到应用程序的WorkbookBeforeClose事件。 它实际上并没有在处理程序中执行任何操作:  

The COM Addin is written in c#. All it does is attach a handler to the application's WorkbookBeforeClose event.  It doesn't actually do anything in the handler:  

/// <summary>
		///      Implements the OnConnection method of the IDTExtensibility2 interface.
		///      Receives notification that the Add-in is being loaded.
		/// </summary>
		/// <param term='application'>
		///      Root object of the host application.
		/// </param>
		/// <param term='connectMode'>
		///      Describes how the Add-in is being loaded.
		/// </param>
		/// <param term='addInInst'>
		///      Object representing this Add-in.
		/// </param>
		/// <seealso class='IDTExtensibility2' />
		public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom)
		{
			applicationObject = application as Application;
            applicationObject.WorkbookBeforeClose += new AppEvents_WorkbookBeforeCloseEventHandler(applicationObject_WorkbookBeforeClose);
		}


安装了com加载项后,启动excel,然后加载包含vba代码的工作簿,然后关闭excel,系统将提示您输入vba密码两次。

请注意,到目前为止,如果您在VBA插件中打开用户表单,我只能重现该错误。 我使用的其他VBA代码没有重现该bug,但我没有尝试过所有内容。

When you have the com add-in installed, start excel and then load a workbook with your vba code in it, then close excel and you will be prompted for the vba password twice.

Note that so far the I can only reproduce the bug if you open a userform in the VBA addin.  Other VBA code I've used doesn't reproduce the bug, but I haven't tried everything.

此外,还有其他方法可以从COM加载项中触发错误除了将处理程序附加到事件之外,但这是一个非常简单的事件。

Also, there may be other ways to trigger the bug from your COM add-in other than attaching a handler to an event, but that is a very simple one I have found.

我不是Excel加载项的专家,所以如果我感激不尽,任何人都可以告诉我我在非常简单的插件中所做的任何事情都是不正确的。  然而,它们如此简单,对我来说看起来像是一个Excel Bug?

I'm not an expert on Excel Add-ins, so I'd be grateful if anyone can tell me of anything I've done in my very simple addins that is not correct.  however, they are so simple it looks like an Excel Bug to me??

非常感谢您的帮助!

Bill

推荐答案

比尔,

我会就这个问题咨询我的同事,这需要一些时间。非常感谢您的耐心。

I will consult my colleagues on this issue, and it will take some time. Your patience will be greatly appreciated.

问候,

Jeffrey


这篇关于COM加载项和VBA密码提示错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆