Execute multiple tracked actions in VBA

Hello

When I activate my plotter, it should initialize (about 30sec). In the meantime I'd just like to display a UserForm that says we have to wait and that removes once the initialization of the plotter is complete.

My problem is that:

If I tell VBA to initialize the plotter and then open the userform, the userform opens after 30 seconds.
Conversely, if I say open the userform first, then the rest of the code executes once the userform is closed.

 

Do you have any idea how I can fix or work around this? Thank you.

Why not create 2 macrox for the 2 operations, and then make a macro that calls these 2 macros?

 

After that, I'm a quiche in vba ^^

2 Likes

Hello

Want to insert a loading bar during the initialization time?

[edit] I'm also a VBA quiche

1 Like

Hello

Why not insert the rest of the code into the userform (with a right click on it)?

Edit: see here, that's what I was proposing:

http://www.excelabo.net/excel/userform_message

Show and hide userform with .show and .hide

1 Like

Hello

In fact, you launch your userform.

Then you launch the plotter (By the way, what is it?). When the task is finished, you close the userform.

 

 

1 Like

Here is a tutorial for a progress bar: http://www.blog-excel.com/barre-de-progression-excel/

+1 Lucas!

1 Like

@Aurelien: In macro it is not recommended to use ProgressBars. Indeed, for it to work properly, it would require multithreaded management (management of several tasks at the same time). Because if not, the bar "freezes" during the execution of the macro and is therefore useless.

2 Likes

Here is a quick macro that illustrates the problem.

 

When the macro is launched, UserForm1 is displayed. Once we close it, UserForm2 opens and once it closes one by one MessageBox.

http://cloud.winlap.ch/download/455

This is exactly the problem I have with my plotter, for example I would have to open my two userforms at the same time.

 

Thank you

 

Edit:

Ah I just saw .PL's message, I didn't know that there was the "_activate" method, I knew "_initialize" for excel but it didn't work on SW or I had made a mistake. I'll keep you informed, thank you!

Edit2:

It doesn't work. Could I ask you to test your solution on the macro I uploaded? To find out if I was the one who made a mistake. Thank you

1 Like

Apparently you have to look with Doevents to see: https://support.office.com/fr-fr/article/DoEvents-fonction-7af41eca-88e0-470d-adaf-0b3d4c2575b0

Which eliminates what I said previously about the progressbar. ;-)

Ah I think I just found a solution!!

 

Adding "vbModeless" after the "UserForm.Show" seems to work. To check

PS: Thanks rem, but in fact I didn't really understand the usefulness of DoEvents?

Tosummarize, DoEvents allows you to wait until an action is completely completed before continuing the procedure.

So it allows you to pause the program in a clean way and not run in a vacuum overloading the processor with useless calculations to wait.

Thank you for your answer,

because the window opens well but the content does not load (So white window) and the window loads once the action is completed.

 

I apologize now and already if I won't be active in the next two weeks (holidays).