VBA users: help me understand how to use the CorelDraw progress bar, AppStatus, etc.?

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 Long

Application.Status.BeginProgress

For count1 = 1 To 10

Application.Status.progress = count1 / 10 * 100

MsgBox "The count is " & count1

Next count1

Application.Status.EndProgress

End 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.BeginProgress

End 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.

  • Former Member
    0 Former Member over 7 years ago

    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: