Excel

Status Bar Messages

Ease of Use

Easy

Version tested with

2000, 2002 

Submitted by:

Justinlabenne

Description:

Create animated statusbar messages 

Discussion:

Easy enhancement you can add to your workbook. Instead of a plain message that sits on the statusbar, deliver a custom message that can scroll in different directions and blink. Can be used to deliver important updates, or deliver messages while a procedure is running, etc... 

Code:

instructions for use

			

Option Explicit 'Api declaration for suspending operation for a specified time Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Sub StatusMessage_Full() ' Text strings that will be shown Const sz1stMsg As String = "NEW KB ALERT!!!!" Const sz2ndMsg As String = "Log onto www.vbaexpress.com" Const sz3rdMsg As String = "and Check out the kb!....." Dim lCount As Long Dim lMsgLen As Long Dim i As Long Dim bExit As Boolean ' Blink an alert on the StatusBar first ' ================================================================= While bExit = False DoEvents Application.StatusBar = sz1stMsg Sleep 600& Application.StatusBar = Empty Sleep 600& lCount = lCount + 1 If lCount = 3 Then bExit = True Wend ' ================================================================= ' Then scroll the second message ' ================================================================= lMsgLen = Len(sz2ndMsg) For i = 1 To lMsgLen Sleep 80& DoEvents Application.StatusBar = Left$(sz2ndMsg, i) Next Sleep 100& ' ================================================================= ' Reset the loop check / Counter bExit = False lCount = 0 ' Deliver the 3rd and final message ' ================================================================= lMsgLen = Len(sz3rdMsg) While bExit = False For i = 1 To lMsgLen * 2 Sleep 80& DoEvents Application.StatusBar = Mid$(Space(lMsgLen) & sz3rdMsg, i, lMsgLen) Next lCount = lCount + 1 ' in case loop counter {lCount} did not reset from first loop procedure, ' we add a check for a higher number to break out of the possible Endless Loop If lCount >= 1 Then bExit = True ' If the loop counter is met, we exit the loop If bExit Then Application.StatusBar = Empty End End If Wend End Sub

How to use:

  1. Open an Excel Workbook
  2. Copy the code
  3. Press Alt + F11 to open the Visual Basic Editor (VBE)
  4. Select INSERT > MODULE from the menubar
  5. Paste code into the right pane
  6. Press Alt+Q to return to Excel
  7. Save workbook before any other changes
 

Test the code:

  1. Go to TOOLS > MACRO > MACROS
  2. When the dialog appears, select {StatusMessage_Full}
  3. Press Run
  4. An animated message will scroll across the statusbar
 

Sample File:

Statbar msg.zip 11.15KB 

Approved by mdmackillop


This entry has been viewed 391 times.

Please read our Legal Information and Privacy Policy
Copyright @2004 - 2020 VBA Express