开发者

What is the bare minimum VBA "I'm busy" dialog?

开发者 https://www.devze.com 2023-03-03 20:19 出处:网络
I\'ve got a macro in PowerPoint 2010 that links audio files to each and every slide.However, this takes some time, and although there is a status bar \"linking files\" progress, I would like something

I've got a macro in PowerPoint 2010 that links audio files to each and every slide. However, this takes some time, and although there is a status bar "linking files" progress, I would like something more In your face.

Caveat: I'm really not familiar with VBA or 开发者_运维知识库it's API.

What I want:

ImBusyDialog("Linking Files...").Open()

// Call Sub that does real work.

ImBusyDialog.Close();

and that's it. If there's something built in like the page loading spinner in IE, then great, if not, I'm happy with a simple message box. The important thing is that it require no user intervention.


Use the same logic as you do to set the status bar. Where you set the statusbar text, you'll simply add the appropriate code to call a status dialog box.

O'Reilly has a rather detailed description on how to build a status bar dialog box with a progress bar and everything. It is probably a bit overkill for what you want, but more to see what is possible in VBA: http://oreilly.com/pub/h/2607

Stackoverflow has dealt with this issue before as well with a relatively simple box you could easily modify to show which file is being worked on an any given moment: How do I create a status dialog box in Excel

The important code from the previous post:

Sub ShowForm_DoSomething()r
Load frmStatus
     frmStatus.Label1.Caption = "Starting"
     frmStatus.Show
     frmStatus.Repaint
'Load the form and set text
     frmStatus.Label1.Caption = "Doing something"
     frmStatus.Repaint
'code here to perform an action
      frmStatus.Label1.Caption = "Doing something else"
     frmStatus.Repaint
'code here to perform an action
      frmStatus.Label1.Caption = "Finished"
     frmStatus.Repaint
     Application.Wait (Now + TimeValue("0:00:01"))
     frmStatus.Hide
     Unload frmStatus 'hide and unload the form
End Sub

The O'Reilly solution certainly is an involved solution, but it seems the "prettiest" and would probably be very user-friendly. The SO solution appears to be much easier to implement though.

0

精彩评论

暂无评论...
验证码 换一张
取 消