Microsoft Office – Adding a Progress Bar

So a few days ago I published an article about using conditional formatting to create a progress bar in an Excel Worksheet to display, in real-time, the progress of some process to your users.  You can read all the details at:

That said, I then pushed a little further to create a reusable progress bar utilizing a Userform that could be incorporated within any Microsoft Office application and that works as a pop-up overlay to display the progress of a process.

The Solution

By creating a progress bar via a userform, we can now easily export/import the objects into any Microsoft Application :

  • Access
  • Excel
  • Outlook
  • PowerPoint
  • Outlook

and we can customize it to include:

  • Captions
  • Messages
  • Change the color(s)
  • Change the font(s) (color, size, family, …)
  • Anything else we want!

resulting in things like:

Userform Progress Bar 01Helper Function

I have chosen to also use one helper function simply to center the useform.  This is completely optional! Do note this does not work in Access, Outlook.

Sub CenterUserform(oUF As Object)
    With oUF
        .Top = (Application.Height / 2) - (.Height / 2)
        .Left = (Application.Width / 2) - (.Width / 2)
    End With
End Sub

Usage Example

In the Demo I have a simple GenericTest sub which illustrates the basic usage, which would look a little like:

Sub GenericTest()
    'Generic Testing
    Dim i                     As Long
    Const lNoIteration As Long = 73

    ProgressBar.Show
   
    For i = 1 To lNoIteration
        ProgressBar.ProgressBar_Progress (i / lNoIteration)
    Next i
End Sub

Or adding a few options to customize it a little:

Sub GenericTest()
    'Generic Testing
    Dim i                     As Long
    Const lNoIteration As Long = 73

    ProgressBar.Show
    Call CenterUserform(ProgressBar) 'Only works in Excel, PowerPoint, Word
    ProgressBar.ProgressBar_ProgressOverlay True    'Place the % value on top of the progress bar
    ProgressBar.ProgressBar_Resize 150, 325         'Resize the userform (smaller in this case)
    ProgressBar.ProgressBar_Color RGB(253, 109, 13) 'Change progress bar color - Orange
    ProgressBar.ProgressBar_Caption "Progress Bar Simulation" 'Add a form caption
    ProgressBar.ProgressBar_Message1 "Here's a demonstration of an Excel Userform Progress Bar." & vbCrLf & vbCrLf & "Enjoy!"
    ProgressBar.ProgressBar_Message2_Align fmTextAlignCenter 'Center align the Message2 content

    For i = 1 To lNoIteration
        ProgressBar.ProgressBar_Message2 "Iteration " & Chr(10) & i
        ProgressBar.ProgressBar_Progress (i / lNoIteration)
        Sleep 25
    Next i
    
    ProgressBar.ProgressBar_Message2 "Operation Completed Successfully!"
End Sub

Correction!

I stated erroneously, in my YouTube video, that Microsoft Access didn’t support the Userform Progress Bar, but Carsten Gromberg was kind enough to correct me on this in the comments below. I incorrectly assumed, that since the userform option did not appear in Microsoft Accesss VBE menu or toolbar as an option

VBE - Insert Options

that it wasn’t in fact supported.

As Carsten pointed out, this is false. Userforms are fully supported. So we can import the same userform in Access and use it in the same manner. As he mentions, by importing the userform, Access will automatically add the necessary ‘Microsoft Forms 2.0 Object Library’ reference to the VBA project.

Also note that you can customize the VBE and drag the Userform command into the menu and/or toolbar so it is available.

A great big Thank you to Carsten for teaching this old dog a new trick!

Download The Demo File

Feel free to download a 100% unlocked copy (includes an Access, Excel and Word Demo Files) by using the link provided below:

Download “Userform - Progress Bar” UserForm-Progress-Bar.zip – Downloaded 7605 times – 64.65 KB
Important Notice
All code samples, download samples, links, … on this site are provided ‘AS IS’.

In no event will Devhut.net or CARDA Consultants Inc. be liable to the client/end-user or any third party for any damages, including any lost profits, lost savings or other incidental, consequential or special damages arising out of the operation of or inability to operate the software which CARDA Consultants Inc. has provided, even if CARDA Consultants Inc. has been advised of the possibility of such damages.

3 responses on “Microsoft Office – Adding a Progress Bar

  1. Carsten Gromberg

    Dear Daniel, thanks a lot for your good and inspiring work!

    Regarding the recent Progress-Bar-Topic I wonder why you mentioned in this article “excluding Microsoft Access as it doesn’t support userforms”? Yesterday you even produced an extra video to present a solution with an Access Standard Form for displaying the Progress Bar.

    But this is not necessary at all, because Access very well supports user forms! You can test it by importing your files (especially the ProgressBar.frm) direct in the VBA-IDE. There you can insert and maintain userforms. -> Access automatical inserts a reference to the “Microsoft Forms 2.0 Object Library”, which controls you are able to place on that userform.

    I am looking forward for all the ideas for Access you will present your audience in the near future with this “new” tool in your box.

    Best wishes, Carsten

    1. Daniel Pineault Post author

      Well you just taught this old dog a new trick!

      I assumed (there was my mistake) that since there was no Userform option in the Access VBE

      VBE - Insert Options

      that it wasn’t possible and never even attempted to import my previous solution.

      I’ll have to make a correction to that statement. Thank you for sharing, now I have something to go an investigate a little.

  2. Carsten Gromberg

    Yes, in a standard installation the menu entry for inserting an userform is not present. But you can modify this manually by customizing the toolbar.