top of page
The VBA Help blog
Search
Automatically add Windows API declaration(s)
VBE_Extras will help you to identify and add (to your VBA code) Windows API declarations.
Aug 18, 20256 min read


MsgBox with custom button texts
This post provides code that you can use to customise the text in message box buttons. You can show the message box with 1, 2 or 3 buttons and get the text of the clicked button back.
Jun 19, 20253 min read


MsgBox with a timeout
Showing a MsgBox dialog to a user is great to inform them of stuff or get input. But it can be a problem if the user isn't paying attention to your application and doesn't notice the dialog. But a dialog with a timeout ... using the Windows API function "MessageBoxTimeout" ... won't wait indefinitely ... it'll wait as long as you want it to wait.
Jun 11, 20254 min read


Get the application window handle in any app (well ... in Excel, Word, Access, PowerPoint or Outlook)
I wanted to have a simple piece of code that I could drop into any host application in which I am developing VBA code that would get me the application window handle ...
Jun 10, 20252 min read


A better Application.OnTime ... run your VBA code to the nearest millisecond (ish)
Application.OnTime is great if you want to call your procedure to the nearest second. What do you do if you want finer control than that?
Aug 31, 20233 min read


Make a UserForm transparent
The following code will make the entire UserForm transparent. I'm sure there is a practical use for this, I'm just now sure what it is! 1. In the UserForm's code in the declarations area, add the Windows API calls and associated constants 2. And in the UserForm's code area below the declarations, add the SetTransparency procedure 3. And from the UserForm_Initialize event, call the SetTransparency procedure 4. That's it. The only thing left to do is to display the User
Feb 26, 20221 min read


Hide a UserForm's title bar
The following code will hide the whole title bar of the UserForm window. Why would you want to do this? The only time I do is when showing a modeless 'progress bar' dialog. 1. In the UserForm's code in the declarations area, add the Windows API calls and associated constants 2. And in the UserForm's code in the procedures area, add this SetNoTitleBar procedure 3. And from the UserForm_Initialize event, call the SetNoTitleBar procedure 4. Display the UserForm (in this exam
Feb 25, 20221 min read


Working with a UserForm's close button (the 'X' button)
The close (or 'X') button appears at the right in the title bar of every UserForm. You can control the behaviour when it is clicked, or you can hide it. Why would you want to do that? Normally, you wouldn't. And shouldn't. Normally the user should be able to close a UserForm whenever they want and your code should handle that outcome. However, just occasionally, it might be essential to ensure that a user has acknowledged some text or made a selection ... an example might be
Feb 25, 20222 min read


Add an icon to a UserForm's title bar
Adding an icon to a UserForm's title bar can help to give a professional look to your UserForm. The source icon must be a .ico file. If the image file you want to use is not a .ico file then you can use one of a number of online image converters to convert it from .jpg or .png etc to .ico ... search along the lines of "convert to icon file". Once you have your .ico file: 1. Add a UserForm to your VBA Project 2. Add an Image control to the UserForm and change its Name proper
Feb 24, 20222 min read


Pause processing
Code often needs to pause and wait for something else to happen. There are a number of options to do this. In Excel, you can use...
Feb 22, 20222 min read


Articles: Blog2
bottom of page