2014-05-09 101 views
2

我有一张工作表加载一个用户窗体的Workbook_Open代码。 关闭表单和工作簿后,Excel会提示我输入VBA项目密码。
我发现这个页面在这个问题上的一些信息:
http://support.microsoft.com/kb/280454
http://social.msdn.microsoft.com/Forums/office/en-US/8cb79e54-26ae-487c-8945-69b84b2e4eeb/com-addins-and-vba-password-prompt-bug关闭Excel时VBA密码提示

但它似乎是一个COM加载项一个问题,我有一些。 问题是加载项不是我的,我无法更改或禁用它们。

是否有任何其他的解决办法?

+0

我发现,只要内存因某种原因而损坏,就会发生这种情况 - 因此很难找到问题的根源:例如,读取一个错误的指针引用,当您使用Windows API调用并使用错误的数据类型时(例如Long,LongPtr,..)可能很容易发生。 –

回答

0

我有一些工作簿遇到与某些用户相同的问题。我们经历了检查COM加载项以及Windows和Office的各种组合的过程。

最后,我们将下面的代码作为workbook_beforeclose事件的一部分,并且问题已为我们的用户解决。

Private Sub Workbook_BeforeClose(Cancel As Boolean) 

Dim intResponse as Integer 

'If the workbook needs to be saved then ask the user if they want to save the workbook, if not then exit without saving 
'Need a global boolean to ensure the request to save the workbook is not shown twice 
If Not ThisWorkbook.Saved And Not blnStartedClose Then 
    blnStartedClose = True 
    intResponse = MsgBox("Do you want to Save the this Workbook" & vbNewLine & vbNewLine & _ 
         "Select 'Yes' to save the workbook" & vbNewLine & _ 
         "Select 'No' to close without saving", vbYesNo, "Confirm - Workbook Save?") 
    If intResponse = vbYes Then ThisWorkbook.Save 
End If 

'If the user has clicked on 'No' to save the workbook then reset the "Saved" property to TRUE so that when we exit this routine no attempt to save the workbook is made 
ThisWorkbook.Saved = True 

End Sub 
0

发生这种情况时,您将指针挂到对象。 对于VBA中的每个'Set xyz =',确保您有相应的'Set xyz = Nothing'。 对于任何指向COM对象或从COM对象获取的对象都是类似的。 确保您关闭,使所有对象变量设置为Nothing之前簿可以关闭任何ADO连接等 要特别小心,以处理所有的错误,这些方针的东西:

Option Explicit 
Option Compare Text 
Public Sub Refresh() 
    On Error GoTo FAIL 
    Set wb = ThisWorkbook 
    wb.Activate 
    ' do something useful 
DONE: 
    On Error GoTo 0 
    Set wb = Nothing 
    Exit Sub 
FAIL: 
    MsgBox Err.Description 
    GoTo DONE 
End Sub 
0

我有一些客户有这个问题,我最终在安装BlueBeam Extreme后开始获得它。在关闭我的.xlsm文件时,我未选中COM加载项中的BluebeamOfficeAddIn,并且密码框停止弹出。我要做更多的挖掘,看看它是否是我的代码,但直到现在我还没有这个问题,并禁用该插件似乎帮助...

1

对我来说,问题不是一些加载项或未发布的参考文献。这是Dropbox徽章。只要我删除它,当我关闭Excel时密码不再被请求。要禁用Dropbox徽章,请打开Dropbox应用程序,转到设置,然后选择首选项,然后在常规选项卡中选择Dropbox Badge下的“从不显示”。 我在以下论坛中发现此解决方案: https://www.excelforum.com/excel-programming-vba-macros/1100960-ever-annoying-vba-password-prompt-at-close-of-excel-2.html