Search code examples
vbaoutlookuserform

UserForm in Outlook not responding (can't close, button click event doesn't fire)


I've created a simple UserForm in my Outlook VBA macro - I can make the form visible using this code:

VBA.UserForms.Add (PasswordForm.Name)
PasswordForm.Show (Modal)

...and the UserForm_Initialize() Event does in fact fire. But clicking on the "Submit" button on the form does nothing - the SubmitButton_Click() Event (which was auto-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 this doesn't do anything (the form doesn't close or exit).

Any idea what I might be doing wrong? I'm quite new to VBA.


Solution

  • OK, solved: I changed:

    PasswordForm.Show (Modal)
    

    to

    PasswordForm.Show
    

    and it now works, although I'll have to change the way it works a bit to accommodate the fact that the form won't be modal any more (I suppose it's the better solution anyway, modals can be annoying to the user, it's just I have to check that they submitted the form, etc now).

    Thanks all for your suggestions.