VBA Password Prompting Upon Closing when UserForm is Used

Mike De Salvo

Board Regular
Joined
Jul 11, 2012
Messages
80
I have an interesting reoccuring problem that I can't seem to find answers to. I've developed a UserForm with the following code:

Code:
Option Explicit
Dim col_Selection As New Collection
Private Sub UserForm_Initialize()
Dim Ctl As MSForms.CheckBox
Dim chb_ctl As clsFormEvents
' Go thru the members of the frame and add them to the collection
For Each Ctl In f_Approaches.Controls
    Set chb_ctl = New clsFormEvents
    Set chb_ctl.chb = Ctl
    col_Selection.Add chb_ctl
Next Ctl
End Sub

Private Sub CloseButton_Click()
frm_Setup.Hide
End Sub

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
    MsgBox "Please use the Close or Begin Valuation buttons to close form", vbCritical
    Cancel = True
End If
End Sub

I did not include the individual Command Button codes above as I think they are not relevant to my problem. I have no problems with the UserForm codes or any of the macros in the Workbook. Everything works great until I close the application. UPON CLOSING I GET A PASSWORD PROMPT for Microsoft Visual Basic for Applications. This prompt goes away after I close it 3x pushing the left corner X button, but I would like to eliminate the problem entirely.

This password prompting ONLY OCCURS when I close Excel AFTER SAVING the Workbook. If I choose not to save the document, no password prompting occurs. If I keep Excel opened after closing the Workbook, the password prompt will delay until I close Excel even if it has been several hours past the closing of that workbook. Furthermore, the password prompting only occurs when I use the UserForm macro during that session. If the UserForm macro is not used in that session, it does not occur.

Does anyone have any ideas that might help me isolate the problem and fix it? This problem seems to be fairly common from my search on the web, but no answers. I hope the detail I've provided might bring an Excel-wiz closer to a resolution. Thanks in advance.
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

Forum statistics

Threads
1,215,170
Messages
6,123,422
Members
449,099
Latest member
COOT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top