Visio Guy

Visio Discussions => Programming & Code => Topic started by: scott on October 31, 2008, 08:28:44 PM

Title: taking a break in Visio VBA
Post by: scott on October 31, 2008, 08:28:44 PM
Is there a wait/pause/delay function that is usable in Visio VBA? In Excel VBA there is an Application.wait method but Visio doesn't appear to have one.

I want to display a non-modal message box prior to an operation that's going to take awhile (relatively speaking) and then clear the box when the work is finished. In Excel VBA, this does the trick (PleaseWaitForm is a VBA UserForm):
    Load PleaseWaitForm
    PleaseWaitForm.Show (vbModeless)
    xlApp.Wait (Now + TimeValue("0:00:01"))

    do the work...

    PleaseWaitForm.Hide
    Unload PleaseWaitForm


Anything similar in Visio VBA? Or a totally different technique to achieve the same thing?

Thanks,
Scott
Title: Re: taking a break in Visio VBA
Post by: Paul Herber on November 01, 2008, 01:14:20 PM
If the work bit is going to take a while why do you need a wait period?
Do you know how long it will take and will that not change with different speed PCs?

Title: Re: taking a break in Visio VBA
Post by: vojo on November 02, 2008, 03:11:59 PM
its crude and brute force....but I used the timer function for the visio animation stuff I posted here
It appeared to have decent control/resolution...increments of about 150ms on my T60p
Title: Re: taking a break in Visio VBA
Post by: AndyW on November 03, 2008, 08:01:08 AM
Are you looking to have the form displayed for a minimum amount of time, if the work is completed sooner. If not, you have no need of the delay.

If you want the form for a minimum time or until the work has completed,

Public Declare Sub Sleep Lib "kernel32" ( ByVal dwMilliseconds As Long)

dim sTime as single

stime = Timer

pleaseWaitForm.show(vbModeless)

... do work ...

if Abs(Timer - sTime) < FORM_DISPLAY_SECS then
    call Sleep abs(time-stime)*1000
endif

pleaseWaitForm.hide

Title: Re: taking a break in Visio VBA
Post by: Michael Dag on November 03, 2008, 11:37:23 AM
Maybe I am missing the point of this...
but what is your intention with the form?
to inform the user work is being done and it could take a while?

why not use a form with a progress bar moving from 0 to 100% ?

it'll inform the user work is being done and won't detain them any
longer then neccessary...
Title: Re: taking a break in Visio VBA
Post by: scott on November 05, 2008, 05:43:12 AM
Thanks for the suggestions. To answer a couple of the questions:
Browser ID: smf (is_webkit)
Templates: 1: Printpage (default).
Sub templates: 4: init, print_above, main, print_below.
Language files: 1: index+Modifications.english (default).
Style sheets: 0: .
Hooks called: 60 (show)
Files included: 25 - 925KB. (show)
Memory used: 747KB.
Tokens: post-login.
Cache hits: 8: 0.00120s for 22,301 bytes (show)
Cache misses: 2: (show)
Queries used: 11.

[Show Queries]