Alerts

Alert Messages with a Lightbox for Excel

Version 1
07Nov 2016

Alerts Documentation

By: Mark Kubiszyn


Alerts for Excel Screenshot



Alerts are simple Excel messages that popup over a LightBox. Choose from 4 different Alert Types, vbSuccess, vbWarning, vbInfo (use for Information/Help) and vbDanger (use for Critical Issue/Errors). Alerts can be wider or taller and can show or hide a Title / Message that can also be formatted in HTML. You can dismiss Alerts by clicking on the small cross, by clicking anywhere on the LightBox or by pressing the Escape Key

FEATURES

- create messages with a lightbox effect
- abort by closing the alert, by clicking anywhere on the lightbox or by the Escape key
- change the Alert Title and Alert Message
- change the Dialog Title, Message Title and Message Font Sizes
- use HTML formatting for the Message
- the HTML, CSS & Javascript shows you how to:
  prevent F5 and CTRL+F5 from being pressed
  prevent the Right-click context menu from being displayed
  prevent Text Selections for the Body
  remove all scrollbars from a WebBrowser Control

REQUIRED

Excel 2010 or Excel 2013 (32bit or 64bit), working with Windows 7 & 10
Some knowledge of VBA to Copy & Paste Code into respective Code Modules in your own Projects

Configuring Alerts - A Handful of Simple Settings

Configuring Alerts is straightforward. Here is the Code to create a simple Success Alert:

 
    AlertBox.Initialise vbSuccess
    AlertBox.DisplayMessage "Success ", "- your request has been processed"
 

Success Alert
Here is the Code to create a more advanced Alert as a Formatted HTML Message without a Bar or a Title using Named Properties:
 
    AlertBox.Initialise Alert:=vbSuccess, _
                      				  BarWidth:="0px", _
                    		    	  AlertHeight:=120, _
                     	  			  PreventEscapeDismissingAlert:=True

    AlertBox.DisplayMessage AlertTitle:="", _
                           						  AlertMessage:="Here's a message

Oops...
Something went wrong!", _ DismissByLightBoxClick:=False  

Alerts HTML Formatted
Here are all of the Alert Types, vbSuccess, vbWarning, vbInfo and vbDanger:

Success
Warning
Info Help
Danger Error
Here is a list of the available Parameters for the Initialise() Function:
 
   Alert:=vbSuccess, vbWarning, vbInfo, vbDanger

   BarWidth:="10px"

   AllowMessageTextSelection:=False, True

   HideCloseCross:=False, True

   PreventEscapeDismissingAlert:=False, True

   AlertWidth:=400

   AlertHeight:=300
 
Here is a list of the available Parameters for the DisplayMessage() Function:
 
   AlertTitle:="Success "

   AlertMessage:="- your request has been processed"

   DismissByLightBoxClick:=True, False
 
You can also change the LightBox to be a Black LightBox:
 
    ' - change this to use a Black LightBox or a White LightBox (LightBox UserForm Settings)
    Private Const lngLightBoxColour As Long = vbWhite
 
Copying the Code into Your Own Projects

To use Alerts in your own Projects, you can simply start a Project from scratch using the Alerts Workbook (you can remove the 'License' Worksheet) or you can Export the 2 UserForm .BAS Files from the Alerts Workbook and then Import them back into your own Project. Then use the examples that accompany the Software or one of the examples above

CHANGELOG

08.11.2016 - (Version 1) released