# Msg

Version 1.0.1

## Introduction

If you have already purchased this Software, let me take a moment to thank you for being a loyal customer

This documentation is to help you understand the Software and to give you a more meaningful insight into what it can do. Please go through the documentation and read it carefully · Basic to moderate VBA skills will be required

#### Requirements

You will need the following Excel Version & Prerequisite to use this Software

1. Excel 2010, 2013 & 2016 (32bit or 64bit)
2. Basic to moderate VBA skills
3. Access to the VBOM (a setting in Excel) & Macro's must be enabled
4. Windows PC · NOT a Mac!

No support is provided for customization or development of this Software

Msg is a bespoke HTML/CSS/Javascript notification Message box with hover buttons, Icons & Preloaders for Excel to inform users of success/info, errors, warnings and help, featuring a lightbox overlay for Excel. You can display a Message that has a timeout and will disappear after a specific duration. Msg comes in 4 flavours, success/info, critical error, warning and help. Msg, Messages can be triggered from Buttons or Hyperlinks. Users can click anywhere within the LightBox, press Escape or click on the tiny white cross to close the Message. Msg can be used whilst a task is running using a Callback feature. Msg is written by Mark Kubiszyn using VBA to embed Icons, Images and animated GIF's into Memory which will follow the Workbook when distributed. The embedded Javascript/HTML/CSS Code was adapted from Code written in 2009 by Michael Leigeber http://www.leigeber.com/

### Features include:

• * Works with multiple Monitors, centering the Msg Dialog in the middle of the active Monitor
• * Display 4 different types of Message Dialogs, success/info, critical error, warning and help
• * Display a Message for a specific timeout in seconds
• * Display a small Close Cross to dismiss the Dialog
• * Use Icons, Images and Animated GIF's
• * Features 39 Demo Dialog Boxes
• * Improved Fade-In for the Lightbox
• * Use Mapped Hover Buttons for Yes/No or Okay/Cancel Buttons that users can click
• * Button Names and Captions can be changed along with the Widths
• * Prevent the user dismissing the Dialog by clicking on the Lightbox
• * Allow the Dialog to be dismissed by pressing the Escape Key
• * Prevent the user dismissing the Dialog using the CTRL+Break Keypress combination
• * Msg creates a Beautiful, fade-in lightbox effect
• * Msg uses Embedded Base64 encoded images that can be loaded directly or from Files. These are then stored into memory
• * 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

Msg comes as a .ZIP archive, meaning that you need to extract the Files before using the Software. You get 2 main Files featuring 8 Preloaders and 10 Icons (or Images) that are embedded into the Msg Workbook - I also include any Files that are loaded into memory as opposed to Strings of Base64 data. The first File is the main 'Msg.xlsm' File used to Copy into your Project, or to test and develop as your finished Software. The second File is 'Msg - finished.xlsm' which has the Examples removed and is ready for deployment showing a single running Task

Open the 'Msg.xlsm' File and test all of the examples by clicking on the Hyperlinks in Column "B". Lots of examples are in the download File, including Dialogs with timeouts and Dialogs with Icons and Preloaders. Press ALT+F11 to enter the Code Editor and examine the Code. To use Msg you can start a Project from scratch using the 'Msg - finished.xlsm' deployment example, the actual Msg Workbook that you purchased or see the Copy Msg into an Existing Project Section for instructions on adding Msg into your own Projects

After unzipping the Msg.zip File (right-click->Extract Files...) !Important, make a Backup of Msg.xlsm Open both Msg.xlsm (or your Backup File) and your own Macro-enabled Project in the same instance of Excel (I am using a new Project called 'Test.xlsm'). Press ALT+F11 to enter the VBA Editor, Expand all visible Nodes and in the Project Explorer Window, drag the UserForm Code Modules, 'frmLightBox' and 'frmMsg' into your Project from the Msg.xlsm Project. Drag the 'Msg' and 'mdIcons' Code Modules into your Project:

Now select Msg.xlsm and click on the '1' Worksheet. Right-click on the '1' Tab and choose 'Move or Copy...'. In the 'To Book' Dropdown Combo, select your Project, choose 'Before Sheet' and select the first Sheet Name in your Project. !Important - DO NOT CHECK 'Create a Copy' - you need to 'MOVE' the '1' Worksheet otherwise the embedded Icons will not follow the Worksheet. Press the 'OK' Button

That's it, now you can add an Example to one of your Project Code Modules and run a Msg Dialog Box - you can even use the Install Base64 Icons Button if your Project resides in the same Folder as the Msg.xlsm File and the unzipped Base64.txt Files - have fun

You can Compress your finished Files prior to distribution using VBA DecompilerMore a great little free tool

Configuring Msg is straightforward. Msg requires one call at the beginning of your Subroutine to initialise the HTML/CSS/Javascript, default settings in memory and another call to display the actual Message Box or Dialog at another point in your Subroutine

The parameters that must be passed include 'Icon', 'Dialog', 'Caption', and 'Message'. There is also an optional 'Timeout' value that can be passed to automatically close the Message after a period of time ie. 2 seconds. Here is the Code to Initialise and Display a Success Message that the user can close by clicking on the Lightbox or the small Close cross:

    ' initialise
Msg.Init Icon:=icoSuccess

' display the Msg
Msg.Box Dialog:=Success, _
Caption:="Success", _


Here is the Code to Initialise and Display a Success Message that automatically closes after 2 seconds - notice the 'Timeout:=2' added to the end of the Msg.Box() Function and that the Msg does not display the small Close cross

    ' initialise
Msg.Init Icon:=icoSuccess

' display the Msg
Msg.Box Dialog:=Success, _
Caption:="Success", _
Message:="Your request has been processed", _
Timeout:=2


Here is the Code to display a Help Message Dialog:

    ' initialise
Msg.Init Icon:=icoHelp

' display the Msg
Msg.Box Dialog:=Help, _
Caption:="Help", _
Message:="What do you want to do?"


You can display larger Messages with or without an Icon - here is the Code for a Success Dialog with a large Message that has a 'Justify' alignment. Notice that we specify the Dialog Height and Width for this example. You can mix up Text with HTML, so for line breaks I use '<\br />' tags:

    ' initialise
Msg.Init MessageAlignment:=AlignJustify, DialogHeight:=400, DialogWidth:=600

' display the Msg
Msg.Box Dialog:=Success, _
Caption:="Success", _
Message:="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec interdum metus at purus euismod malesuada. Cras tempor tempus bibendum. Duis at nisl lacus. Nulla a luctus magna, ut malesuada massa. Mauris in ligula sed ipsum maximus pharetra. Curabitur at risus iaculis, gravida turpis non, imperdiet lorem. Praesent fermentum suscipit accumsan. Donec fermentum mi volutpat risus ullamcorper, vel egestas eros aliquet. Vivamus eu ornare massa. In id ornare sapien. Vivamus eget dolor efficitur, sodales quam vitae, tempus elit. Duis fringilla nisi quis felis mollis consectetur. Ut elementum vestibulum sem, eget mattis urna hendrerit ac. Morbi vel sapien tincidunt, gravida sem eu, consectetur purus. Sed egestas urna id accumsan ultricies. Ut condimentum tincidunt est et porttitor." & _
"<\br /><\br />" & _
"In velit lectus, auctor nec aliquet a, varius et neque. Cras venenatis sit amet lectus a consequat. Proin suscipit malesuada placerat. Donec imperdiet lacus nunc, sed ultrices enim pellentesque feugiat. Nulla et libero sit amet neque luctus ultricies. Praesent dolor sem, dapibus vel euismod sed, volutpat vitae nisl. Etiam rhoncus eget lectus nec dignissim. Donec aliquam eu dui vehicula tincidunt."



Msg can display hover Buttons and capture the return result. It can also prevent the user dismissing the Dialog by clicking on the Lightbox. Here is the Code to do both using a Help Dialog with 'Yes' and 'No' Buttons (Yes, No and Cancel are all captured using the vbResult Variable):

    ' initialise
Msg.Init ButtonType:=Help, _
YesButton:="Yes", _
YesCaption:="Yes", _
NoButton:="No", _
NoCaption:="No"

' display a Msg and capture the result of the button press
Dim vbResult As VbMsgBoxResult
vbResult = Msg.Box(Dialog:=Help, _
Caption:="Change Setting", _
Message:="Do you wish to accept the changes?", _
DismissByLightBoxClick:=False)

If vbResult = vbYes Then
MsgBox "You pressed the Yes button", vbInformation
ElseIf vbResult = vbNo Then
MsgBox "You pressed the No button", vbInformation
ElseIf vbResult = vbCancel Then
MsgBox "The Help Dialog was cancelled", vbInformation
End If



You don't have to use the Named Arguments when calling the Init() and Box() Functions, you can just omit the Named Arguments using a comma and set all of the Parameters on a single line. This Code will also create a dynamic Hyperlink that when clicked will open the Website in the default Browser. Please Note: a Backslash '\' has been added before the '<\a' attribute so that you can see the Code below, this should be removed if Copying the Code below into your own Project:

    ' initialise
Msg.Init Help, , , , , , , , , , , , , Help, "Add Me", , "Click to Subscribe to my mailing list", , , "64px"

' display a Msg and capture the result of the button press
Dim vbResult As VbMsgBoxResult
vbResult = Msg.Box(Help, "Subscribe", "Subscribe to: <\a href=""http://www.kubiszyn.co.uk/"" style=""color:#0563C1;"" target=""_blank"" title=""click me, I am a hyperlink"">www.kubiszyn.co.uk")

If vbResult = vbYes Then
MsgBox "You pressed the 'Yes please add me to the list' button", vbInformation
End If



Here is a list of Parameters for the Init() and Box() Functions, (marked black) together with examples for each Parameter (where multiple examples are given, you should pass any single occurance as the Parameter):


Init()
Optional Icon As IconType, icoSuccess, icoWarning, icoCriticalError, icoHelp, ldrPreloader, ldrGear
- (depends on the Icon Name given to store in Project - see the Base64Table to see how you can store Icons & Preloaders)

Optional IconPosition As IconPositionType, Center, TopLeft, TopRight, BottomLeft, BottomRight (default)
CenterRight, CenterLeft
- specifies the posistion of the Icon or Preloader

Optional IconSize As Integer, 128 (default), 64, 96
- specifies the size of the Icon or Preloader

Optional DialogWidth As Integer, 400 (default), 960
- specifies the width of the Msg Dialog Box

Optional DialogHeight As Integer, 200 (default but 160 is a nice height to use too), 300, 400
- specifies the height of the Msg Dialog Box

Optional DialogBackgroundColour As String, "#FFFFFF" (default)
- specifies a HTML String to set the Background Colour of the Msg Dialog Box

Optional DismissDialogUsingEscape As Boolean, False (default), True
- specifies whether or not to allow the Msg Dialog Box to be dismissed when a user presses the Escape Button

Optional MessageAlignment As TextAlignType, AlignLeft (default), AlignRight, AlignCenter, AlignJustify
- specifies the alignment of the Message

Optional MessageHeight As Integer, 120 (default)
- specifies the height of the Message

Optional MessagePadding As Integer, 6 (default)
- specifies the padding around the Message

Optional MessageBorderColour As String, "none" (default), "#000000"
- specifies a HTML String to set the Border Colour of the Message

Optional MessageBackgroundColour As String, "transparent" (default), "#000000"
- specifies a HTML String to set the Background Colour of the Message

Optional MessageVerticalScrollbar As Boolean, False (default), True
- specifies whether or not to display a Vertical Scrollbar in the Message

Optional ButtonType As MessageBoxType, Success, CriticalError, Warning, Help
- specifies the Schema of the Button to display

Optional YesButton As String, "Yes", "OK"
- if passed, displays a Button with the passed String as its name

Optional NoButton As String, "No", "Cancel"
- if passed, displays a Button with the passed String as its name

Optional YesCaption As String, "Yes", "Click to Subscribe to the Kubiszyn.co.uk mailing list"
- if passed, displays a Caption when the Button is Hovered over

Optional NoCaption As String, "No", "Click to Cancel the Dialog"
- if passed, displays a Caption when the Button is Hovered over

Optional ButtonTop As String, "10px"
- specifies whereabouts the Button is placed

Optional ButtonWidth As String, "64px"
- specifies the Button width

Optional ButtonHeight As String, "60px"
- specifies the Button height

Optional LineHeight As String, "60px"
- specifies the height of each Text line in a Button

Optional DisplayCloseCross As Boolean = True (default), False
- whether or not to display the small Close Cross shown at the top right of the Msg Dialog Box


Box()
ByVal Dialog As MessageBoxType, Success, CriticalError, Warning, Help
- specifies the type of Msg Dialog that will be displayed

ByVal Caption As String, "Success", "Error", "Warning", "Help"
- specifies the Caption on the Msg Dialog Box Titlebar

ByVal Message As String, "Your request has been processed"
- specifies the Message that will be displayed

Optional Timeout As Integer, 0, 2, 5
- specifies the amount of time that the Msg Dialog Box is displayed before it is closed

Optional DismissByLightBoxClick As Boolean, True (default), False
- whether or not to allow a user to dismiss a Msg Dialog Box by clicking anywhere on the Lightbox

Optional Callback As Variant, "DoTask" (a Subroutine Name to be ran as a Msg Dialog Box is running)
- specifies a Subroutine that can be run after displaying a Msg Dialog Box - the task will update the Msg Dialog Box during the running of the task


One of the things that you will probably want to do is to tweak the Font or Font Size. Msg gives you the ability to tweak a number of things by using 'span style' to change things like the Font Size when passing in your 'Title' or 'Message'. Anything you send in the Message Parameter sets the Pop Boxes 'innerHTML'. For example to change the Font for a Message use the following Code:

' display the Msg
Msg.Box Dialog:=Success, _
Caption:="Success", _



Now you will see the a larger Font Size:

You can use HTML Tags like '<b>' Bold, '<u>' Underline or change the Colour using '<span style='color:Red'>Your request has been processed</span>'

If you would like to Add dynamic content ie. a Hyperlink without using the Link Pop Box then you can easily do this - remember that not everything can be set for the 'innerHTML' ie. Lists, here is the Code to change the Font Colour and add a Hyperlink - notice the use of the target='_blank' to open a new Window for the Link:

MessageText:="This is example content.  You can change this content.  You can add dynamic HTML content www.kubiszyn.co.uk"



Please Note: some characters need to be 'Slashed' out so that they will accepted by the Javascript - these include the ' (apostrophe) ie. \'

All Icons and Loaders are embedded into Sheet"1" or 'shtMsg' (Worksheet Code Module Name). This Sheet has a Table called 'Base64Table'. Default Icons and Preloaders (animations) have been added at the top of the Table. You can configure this Table to load from Base64 Encoded, embedded Text or to load the data from a File. To load a new Icon, you need to adjust the Table to specify the following:

' Base64Table
Column 1 Icon or Loader Name icoSuccess, icoWarning, icoCriticalError, icoHelp, ldrGear, ldrRotator, ldrMagnifier
- specifies a Name for the Icon or Preloader animation which will be added to the mdIcons Code Module as an
Enum 'IconType'

Column 2 UID 1, 2, 3
- specifies a unique ID for the Icon or Preloader animation - this is a Formula that generates the next whole
Integer
- if this Formula appears currupt after editing the Table, simply Copy down the first Formula or just number
your Icons consecutively ie. 1, 2, 3 etc.

Column 3 Load from File Y, N
- specifies whether or not to load the data from a File or from the Table, this can be lower or upper case

Column 4 Base64 Encoded Data or Filename (depends on Y/N for Load from File option)
'C:\Archive\- a_My Programming\- a_My Excel\Working\Msg\bar2.txt'
- specifies the Base64 Encoded Text or a Filename including the full Filepath to a Text File containing
the Base64 Encoded data
- Please Note: this can be just a Filename, but the File has to be in the same Folder as the 'Msg' Workbook
- for examples of Base64 Data Strings, see the next Section 'Msg Base64 Encoded Icons'



If an Error occurs the Code written to the 'mdIcons' Code Module will no longer include the Names of your Icons or Preloaders and you will recieve an Error when further compiling 'Msg'. An Error message will also be present in the 'mdIcons' Code Module. To rectify this you need to ensure everthing in the 'base64Table' is configured correctly. When making any major changes, please ensure that you backup 'Msg' first

Here are examples of Base64 Encoded Icons (these are the 4 main Icons used by Msg) - you can use www.base64image.org or Motobit (Icons) to Base64 Encode an image or Motobit (Web Images) for Web-based Images. Please Note: you need to leave these 4 by default in the Table, however after developing your Msg Project, you can completely remove the Table and use Sheet("1") as a normal Worksheet as all of the data is compressed and hidden within the Worksheet to travel with your Project - you should also remove all of the Code used to load Icons from the 'mdMsg' Code Module

' icoSuccess

' icoWarning

' icoCriticalError

' icoHelp



When using the encoded data, please ensure that you add the relevant prefix for an image ie. for a 'png' encoded image, add: 'data:image/png;base64,/' (the last forward slash before the data is optional

If your encoded data is too large for the Table, you should load it from File. Once installed you do not have to keep reloading it - the data is compressed and encrypted into the Worksheet

You may wish to use a Table as a Config Table ie. Icon Number, Dialog Number, Caption and Message and refer to the Row that you want to populate 'Msg.Init()' and 'Msg.Box()' with. Here is the Code to do that (add 'Table1' in 'Sheet1' with the headers, Icon, Dialog, Caption and Message, then run the Code setting the Const to the Index number for the Table Row to pick the settings from, fig. 1). I have made a Table that you can pick the Icon Types and Dialog Types from using Data Validation (fig. 2):

#### Fig 2.

Public Sub Example_Pick_Index4()

Const Index As Long = 4

' initialise
Msg.Init Icon:=Worksheets("Sheet1").ListObjects("Table1").ListColumns("Icon").DataBodyRange(Index), _
IconPosition:=CenterRight, DialogHeight:=140

' display the Msg
Msg.Box Dialog:=Worksheets("Sheet1").ListObjects("Table1").ListColumns("Dialog").DataBodyRange(Index), _
Caption:=Worksheets("Sheet1").ListObjects("Table1").ListColumns("Caption").DataBodyRange(Index), _
Message:=Worksheets("Sheet1").ListObjects("Table1").ListColumns("Message").DataBodyRange(Index)

End Sub


I have included a few settings that can be tweaked by developers. You can find these at the top of both UserForm Code Modules. You can tweak the Light Box Darkness, the Light Box Timer Speed and the Light Box Transparency Step. For example if you would like a slightly darker LightBox then you would adjust the following setting in the Msg UserForm Code Module from '60' to '80'


' // configurable vars for developers
' - use this to deepen the LightBox Colour effect
'   default 0:=Lightest, 100:=Darkest
Private Const intLightBoxDarkness As Integer = 80


When using the setting above you can also adjust the speed of the LightBox by tweaking the Transparency Step from '8' to '14'. Now the darker LightBox will also fade in at the same rate or slightly faster:


' - increase this if using a darker LightBoxOpacity to speed up the LightBox Fade
'   ie. LightBoxOpacity = 80, intLightBoxTransparencyStep = 14
Private Const intLightBoxTransparencyStep As Integer = 14


If you prefer an even faster, smoother fade speed, you can also tweak the LightBox Timer Speed from '0.02' to '0.01':


' // configurable vars for developers
' - you can adjust this but ideally only between 0.01 -> 0.03
'   use the Transparency Step when using a darker LightBox
Private Const dblLightBoxTimerSpeed As Double = '0.01'


There are 4 types of standard Msg Dialogs Boxes available. Here they are together with their respective standard Icons and Messages - MessageAlignment is 'AlignLeft', MessagePadding is standard and the IconPosition is displayed 'BottomRight' (having been designed to fit nicely in this position):

#### 22. Simple Icons - Speech

Please remember you have purchased very affordable Software and you have not paid for a full-time Software design agency - I am but one man. Occasionally I may help with small tweaks, but these requests will be put on a much lower priority due to their nature. You have not PAID for Support, Support is 100% optional and I provide it for your convenience, so please be patient, polite and respectful

### Support (limited) for my Software includes:

* Responding to questions or problems regarding the Software and its features
* Fixing valid (replicated) bugs and reported issues for the VERSION I HAVE WRITTEN

### Software support does not include:

* Customization and installation services
* Support for third party software or ANY kind of development whatsoever

* Make sure your question is a valid Software Issue and not a customization request
* Make sure you have read through the documentation and any related video guides before asking support on how to accomplish a task
* Make sure to double check the Software FAQs or online documentation
* Ensure that you access to the VBOM is allowed and that Macros can run in Excel
* Make sure to provide 'proof of purchase' and state the name / version of the Software that you are having issues with when requesting support by Email or via Facebook

### How to get Support

Contact Mark Kubiszyn on the Email address provided when you purchased the Software, including the Order Number
Contact Kubiszyn.co.uk via our Facebook Page - remember to be patient, if there has been an issue with your download, I will always respond within 48 hours and will Email you the File directly if neccessary or via Messanger. For other issues the response time may be considerably longer and I may choose to respond to specific questions only (as is my right), depending on what has been asked

15.03.2018 - Version 1.0.1. Fixed the 'ReleaseDC' 64bit declaration so instead of returning