UserForm in Outlook is not responding (cannot close, button click event does not fire)
I created a simple UserForm in my Outlook VBA Macro - I can make the form visible with this code:
VBA.UserForms.Add (PasswordForm.Name) PasswordForm.Show (Modal)
... and the UserForm_Initialize()
Event is indeed fire. But clicking on the "Submit" button in the form does nothing - the event SubmitButton_Click()
(which was automatically created by double clicking on the button in the designer) never fires. Also, the UserForm has the usual little red X in the top right corner of the window, but clicking on that does nothing (the form doesn't close or end).
Any idea what I might be doing wrong? I am new to VBA.
a source to share
OK, solved it: I changed:
PasswordForm.Show (Modal)
to
PasswordForm.Show
and now it works, although I will have to change the way it works to accommodate the fact that the form will no longer be modal (I suppose this is the best solution anyway, modals can be annoying to the user, I just have to check what they submitted shape, etc.).
Thanks everyone for your suggestions.
a source to share
Sometimes controls in VBA disconnect from their events. This could be because you renamed the control, or because you accidentally renamed the event procedure (although this rarely happens for other reasons). Also, if you forget to "compile" before running the form, an error may occur in the form that causes the problem.
The easiest way to double check is to open the form in design mode, select the desired button, and press F7. If a new procedure is created, copy paste your code and then just copy / paste the old code into it and get rid of the old one.
After that go to the Debug menu and click Compile. If you find any errors, correct them again by clicking Compile. Repeat until it compiles without complaint. Then try running the form.
a source to share