2014-05-09 109 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