Re: Create "a thing" that shows vba code running
- From: "Rick Rothstein \(MVP - VB\)" <rickNOSPAMnews@xxxxxxxxxxxxxxxxx>
- Date: Fri, 9 Nov 2007 15:03:23 -0500
Is it possible to create "a thing" that shows for the user that some
vba codes are running?
For example, I have four vba codes and it takes a few minutes to
process, but the user can get confused if it is working or not.
Maybe you can make use the following. I have more familiarity with using this code in a compiled VB program, but it seems to work okay on an Excel spread***. The code will change the cursor to the "busy" icon (the spinning hourglass for Windows versions before Vista and that spinning circle for Vista) before your code executes and back to the default icon afterwards. Simply copy/paste the following into the applicable Work*** code window and call your macro (Sub Test() for this example) from the spread*** itself (via Alt+F8 or as the assigned macro for a control, such as a button, located on the ***).
Private Declare Function LoadCursor Lib "user32" _
Alias "LoadCursorA" _
(ByVal hInstance As Long, _
ByVal lpCursorName As Long) As Long
Private Declare Function SetCursor Lib "user32" _
(ByVal hCursor As Long) As Long
Dim HoldCursor As Long ' Receives handle of default cursor
Dim NewCursor As Long ' Newly created cursor
Const IDC_WAIT = 32514&
Sub Test()
NewCursor = LoadCursor(ByVal 0&, IDC_WAIT)
HoldCursor = SetCursor(NewCursor)
'
' Your code goes here -- the MsgBox statement is just an example
'
MsgBox "Hello"
SetCursor HoldCursor
End Sub
Note: I am pretty sure that the spinning icon will only be spinning over the spread*** itself (so if you pop a MessageBox, the cursor won't be busy icon while over the MessageBox even though your code popped it up).
Rick
.
- References:
- Create "a thing" that shows vba code running
- From: gatarossi
- Create "a thing" that shows vba code running
- Prev by Date: Replace Defaults
- Next by Date: Re: Replace Defaults
- Previous by thread: Re: Create "a thing" that shows vba code running
- Next by thread: Re: Create "a thing" that shows vba code running
- Index(es):