Excel

Updated StatusBar Message From Online Workbook

Ease of Use

Easy

Version tested with

2000, 2002 

Submitted by:

Justinlabenne

Description:

Links to an Excel workbook on a website obtaining an message stored in a cell, that is then delivered to the user via the statusbar. 

Discussion:

An easy way to provide updated messages to the users of your Excel files. The message is scrolled 3 times across the statusbar after it is retrieved. Can be used to provide info about a new version of the workbook being available or to give the user alerts about something relevent to the workbook. There are many possible uses that can be customized to suit the need. 

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 GetUpdatedMessage() ' Turn off screen-updating and disable the canceling the procedure ' while the internet connection is being made With Application .ScreenUpdating = False .EnableCancelKey = xlDisabled On Error GoTo ErrorProcedure ' Opens and Excel file on the internet .Workbooks.Open ("http://www.jlxl.net/JLXLVersionControl.xls") Dim szNewMsg As String ' Checks for the value in cell A3 of the remote workbook ' and stores it in a variable szNewMsg = Range("A3").Value ' Then close the workbook .Workbooks("JLXLVersionControl.xls").Close savechanges:=False .EnableCancelKey = xlInterrupt .ScreenUpdating = True End With ' Determine the updated string's length Dim lMsgLen As Long lMsgLen = Len(szNewMsg) ' Our counter variable Dim lCount As Long Do Dim i As Long For i = 1 To lMsgLen * 2 ' Create a pause Sleep 80& DoEvents ' The rotating message Application.StatusBar = Mid$(Space(lMsgLen) & szNewMsg, i, lMsgLen) Next i ' Increment our {Do} loop counter lCount = lCount + 1 ' When our counter reaches 3, were done: Loop Until lCount = 3 ' So clear the StatusBar Application.StatusBar = Empty Exit Sub ErrorProcedure: MsgBox Err.Description Application.ScreenUpdating = True Application.EnableCancelKey = xlInterrupt 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. The example file runs on the Opening of the Workbook
  2. You can run at any time by going to
  3. TOOLS > MACRO > MACROS
  4. Selecting {GetUpdatedMessage} from the dialog box
  5. Pressing {Run}
  6. A message will soon scroll across the StatusBar
 

Sample File:

StatBar_UpdatedMsg.zip 11.05KB 

Approved by mdmackillop


This entry has been viewed 177 times.

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