How to work around modeless userform continuing main script?

Started by freshlychurnedbutter, February 20, 2022, 03:35:15 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

freshlychurnedbutter

In my "Main" sub, I call a modeless userform which asks the user to select a shape in the drawing and then hit "OK" on the userform to collect some information of that selected shape. My problem is that as soon as the userform is called via
Userform.Show vbModeless
the script continues on to the next line of the "Main" sub. Is there a way to work around this? Ideally I need the "Main" sub to pause when I summon the userform and resume once the userform is closed. Any idea how? I know if I use a message box instead, it pauses the "Main" sub but it doesn't allow the user to interact with the drawing while it's popped up.

The way I have it right now, I have to abandon the "Main" sub as soon as the userform is summoned and need to call my next sub at the SubmitButton_Click sub in the userform code. This really limits flexibility in my code. Thoughts on this? Thanks!

Yacine

Yacine

freshlychurnedbutter

Problem with that is that a modal userform will prevent the user from interacting with the drawing. While the userform is popped up, the user needs to click on a shape to select it. The code then takes that user made selection to do other stuff.

wapperdude

When you call the form, you need to set it to Modeless.  The code snippet below calls a form named CountConns.  It is part of the development in the link provided.


Sub ShowCountConns()
'Invokes non-model userform.  The userform "launches" the analysis.
'
    CountConns.Show vbModeless
End Sub


Here's example using such a Form:  http://visguy.com/vgforum/index.php?topic=6373.msg26266.
Visio 2019 Pro