0

I need to write a code where it will be possible to deactivate userform when user clicks outside area of userform or another workbook.

I tried

Userform.Show vbModeless

but it does not give the result I want, when I am clicking back to userform it is impossible to activate it.

For note, I am using wb open { userform.show 0} and whole dblclicking inside sheet.

I think the inizialization or activate will help me. Any ideas?

xlmaster
  • 659
  • 7
  • 23

1 Answers1

1

UserForm is the generic type for all UserForms, but user-created UserForms have a special name, by default UserForm1, Userform2, and so on. So the statement should probably be UserForm1.Show vbModeless, not UserForm.Show vbModeless. The actual name of a custom UserForm is the value of the form's Name property.

  • 1
    Fyi Further very interesting reading emphasizing often overlooked aspects, especially that a UserForm *is* a **class** module defining the blueprint of an *object* and how to apply a *Model-View-Presenter* pattern: ["UserForm1.Show?"](https://rubberduckvba.wordpress.com/2017/10/25/userform1-show/) at [Destroy a modeless UserForm properly](https://stackoverflow.com/questions/47357708/vba-destroy-a-modeless-userform-instance-properly) – T.M. Nov 02 '22 at 16:19
  • 1
    Thank you for your useful link, gruß from Heidelberg to Austria. UserForms are difficult to understand because they are reference counted Active-X objects. – Dietrich Baumgarten Nov 03 '22 at 12:23