taking a break in Visio VBA

Started by scott, October 31, 2008, 08:28:44 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

scott

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

Paul Herber

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?

Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

vojo

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

AndyW

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

Live life with an open mind

Michael Dag

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

scott

Thanks for the suggestions. To answer a couple of the questions:

  • Paul: the wait period is just so the form is displayed for at least that long. And I don't really care how long the operation will take, but just want the user to see a (moderately) comforting message such as "work in progress... please wait..." rather than staring at the Visio drawing wondering whether anything is happening.
  • vojo: I'll take a look at your timer function.
  • Andy: Yes, I want the form to display for a minimum amount of time -- just a second or two -- even if the work takes less than that. That's useful but less critical than having the form displayed when the work takes longer.
  • Michael: I could use a progress bar but think that's overkill for my situation.

Browser ID: smf (is_webkit)
Templates: 4: index (default), Display (default), GenericControls (default), GenericControls (default).
Sub templates: 6: init, html_above, body_above, main, body_below, html_below.
Language files: 4: index+Modifications.english (default), Post.english (default), Editor.english (default), Drafts.english (default).
Style sheets: 4: index.css, attachments.css, jquery.sceditor.css, responsive.css.
Hooks called: 237 (show)
Files included: 34 - 1321KB. (show)
Memory used: 1173KB.
Tokens: post-login.
Cache hits: 11: 0.00169s for 26,572 bytes (show)
Cache misses: 1: (show)
Queries used: 13.

[Show Queries]