I'm trying to use the CorelDraw progress bar in a macro, but I'm having trouble.
I've tried this as a simple test:
Sub testing_appstatus()Dim count1 As LongApplication.Status.BeginProgressFor count1 = 1 To 10Application.Status.progress = count1 / 10 * 100MsgBox "The count is " & count1Next count1Application.Status.EndProgressEnd Sub
If I just run the above macro, then I never see the progress bar appear.
If I FIRST run the following macro:
Sub show_progressbar()Application.Status.BeginProgressEnd Sub
then the progress bar is displayed (and stays displayed; I haven't turned it back off).
If I THEN run the macro shown earlier, the progress bar works the way I would expect it to. Each time that it stops, waiting for me to dismiss the message box, I can see that the progress bar has advanced as it should based on count1.
What I'd like to do, of course, is to be able to display, use, and then turn off the progress bar within one macro.
I'm testing this with X7 and X8.
Anybody willing (and able) to help a Corel VBA noob make his ignorance a little bit smaller?
When I try it on a machine that has X5, the first macro, by itself, shows the progress bar as expected. X7 on the same machine - no joy; same behavior as described in my first post.
Myron said:fwiw I tried in X7 and I can see the message popup whereby clicking ok 10 times ends the messages. I have no experience with this but I wouldn't call that a "progress bar". Is that what one should be seeing?
I put the MsgBox line in there just to "freeze" things right after I've updated the progress. I'm only doing that for trying to understand what's going on now; I won't leave it in there once I've resolved how to get the progress bar working.Here's a screenshot showing the progress bar if I've run the other macro first to show the progress bar.
For a correct use you will need create a background worker in your macro, normal loop freeze the CorelDraw UI thread for this reason your progress bar not move. Little code using Task for a C# Macro in CorelDraw X8 64bit (VSTA) [CgsAddInMacro] public void ProgressBar() { this.app.ActiveDocument.Unit = cdrUnit.cdrCentimeter; var t = Task.Run(() => { this.app.Status.BeginProgress(); for (int i = 0; i < 100; i++) { this.app.ActiveDocument.ActiveLayer.CreateRectangle(0+i, 0+i, 1+i, 1+i); this.app.Status.UpdateProgress(1); Thread.Sleep(100); } this.app.Status.EndProgress(); }); } Demo for this code:
https://youtu.be/aWWwITZNy1o
Thank you for showing that.
I don't think I'm having a problem with the progress bar updating during the macro. It does move. I'm having a problem with getting the progress bar to initially display during the macro.
If I display the progress bar using one macro, and don't turn it back off, then it seems to update properly during the next macro I run.
Just thought I would post this tutorial if anyone is looking to add a progress bar to a macro. https://wellsr.com/vba/2017/excel/beautiful-vba-progress-bar-with-step-by-step-instructions/