If you liked Spinner you may also like Preloader a beautiful CSS animating fade in/out spinner written in VBA for Excel that runs in a WebBrowser control on a non-modal transparent Userform with rounded corners, framed Window or a thick bordered Window with Caption.
The guys at Spreadsheet1 have taken the Spinner Project and improved the data storage, added additional Spinners and created a stunning visual demo of Flat Animated Loaders for Excel.
You can view it at:
"As long as the world is turning and spinning, we're gonna be dizzy and we're gonna make mistakes"
"My advice is keep your lips away from the spinning things"
Creating a Spinner
Creating a Spinner is easy. You can choose from 5 different Spinners in two sizes 64x64 pixels and 128x128 pixels. The Code below demonstrates how to select a Spinner and fade it in and out while running a simple task. You can use DoEvents or the alternative Spinner.MyDoEvents to pass messaging back to the main Excel Application whilst running your task. MyDoEvents allows the Excel Application to process more regularly than the normal DoEvents and gives better Control - the downside is that it may slightly increase the task running time as it checks the Windows Messaging system more frequently.
' // fade the Spinner in Spinner.FadeIn PixelBuddhaSpinner:=NewtonsCradle128x128, _ Duration:=1500, _ Disable:=CTRLBreak + MouseKeyboard, _ Position:=ApplicationCenter, _ WaitForDuration:=3000 ' // complete some task ' make sure that your task is long enough to allow the Spinner to Fade in before you start fading it out ' you can adjust the Fade in & Fade out timings accordingly or increase the WaitForDuration to match ' the Fade in time ' use the alternative DoEvents Function which allows better processing control Spinner.MyDoEvents ' // or the regular DoEvents DoEvents ' // fade the Spinner out If Spinner.Running Then Spinner.FadeOut Duration:=1500
SpinnerType Parameter for FadeIn() Subroutine
You can pass any of the following SpinnerType Enum names for the first Parameter of the FadeIn() Subroutine. There are 5 different Spinners available in two sizes 64x64 pixels and 128x128 pixels.
Here are the Spinners you can choose:
Duration Parameter for the FadeIn() Subroutine
Duration is the Fade in duration time Long variable. You can set the Fade in Duration to a Long Value i.e. 3000 (3 seconds approx)
DisableType Parameter for the FadeIn() Subroutine
Disable is a DisableType Enum that allows you to switch off or disable certain combinations including CTRL+Break, Screen drawing, Mouse & Keyboard or Events. To include combinations simply add (+) them together i.e. Disable:=CTRLBreak + Screen
PositionType Parameter for the FadeIn() Subroutine
Position is a PositionType Enum that allows you to center the Spinner on the Screen or Application i.e. Position:=ApplicationCenter
WaitForDuration Parameter for the FadeIn() Subroutine
WaitForDuration is a Long Value that allows you to wait until the Spinner has faded in before continuing with your VBA task i.e WaitForDuration:=3000 (3 seconds approx). This is because you may have a task that cuts off the finish fading of the Spinner because the task exits slightly earlier
SpinnerTransparency Parameter for the FadeIn() Subroutine
SpinnerTransparency (default := True) is a Boolean Value that allows you to set or not set transparency for the UserForm. This allows you to leave the UserForm White to display the Spinner better over non-white Worksheet backgrounds. You can then add a Border as a nice final effect so that it appears in a little Window i.e. SpinnerTransparency:=False
SpinnerBorder Parameter for the FadeIn() Subroutine
SpinnerBorder (default := False) is a Boolean Value that allows you to set or not set a Border for the Spinner i.e.SpinnerBorder:=True
SpinnerBorderColour Parameter for the FadeIn() Subroutine
SpinnerBorderColour (default := vbWhite) is a Long Value that represents an RGB COlour Code so that you can Colour the Border for the Spinner
SpinnerWidth Parameter for the FadeIn() Subroutine
SpinnerWidth is an Integer Value that will set the UserForm Width for the Spinner
SpinnerHeight Parameter for the FadeIn() Subroutine
SpinnerHeight is an Integer Value that will set the UserForm Height for the Spinner
Reducing the UserForm Size
If you only want to use 1 or 2 of the Spinners, you can reduce the File size of the UserForm Code Modules down by removing any unwanted Markup. Press ALT+F11 to enter the Visual Basic Editor. Go to the Load64x64 or Load128x128 Functions and remove any Markup underneath the Spinner Case Statements that you do not require. Additionally, exporting the UserForm out and then re-importing it back in may compress the File size further.
Here are a few Screen Shots of the Spinner in action:
Watch a Video
Watch a Video of the Spinner in action (Please Note: the Spinner is smooth when ran in Excel) :
12 April 2014 - (version 1.1) added extended Parameters into the FadeIn() Subroutine to change Border Colour UserForm Transparency, Spinner background Width & Height and Spinner Width & Height for a little more flexibility allowing you to create a Spinner that will display well ontop of Worksheet Backgrounds other than just white
Fixed an issue with the width & height of the WebBrowser, UserForm and Animated GIF. now only the UserForm Width & Height is adjusted. you can pass in Optional 64 or 128 to resize the Spinner. It's a little neater and now uses the PointsPerPixel Function to return the size of a pixel, in points
14 April 2014 - (version 1.2) minor tweaks to enable the 64bit Version to work in Excel 2013