Transparent Forms
This page describes how you can use a few simple Windows Application
Programmatic Interface (API) functions to create a transparent form.
By default, when you display a UserForm, the UserForm is completely opaque. That is, whatever
lies behind the form cannot be seen. Using a few API functions (Excel 2000 and later with Windows 2000, XP, Vista,
or later -- it will not work on Windows 95, 98, or ME), we can change the forms's opacity from completely visible down to completely invisible (not recommended).
The core to the whole process is the SetLayeredWindowAttributes API functions. We need to use some
support and error checking code, but the real work is done by SetLayeredWindowAttributes. You can
download a bas module with all the code on this page.
The core function in the downloadable module is the
SetFormOpacity function. Its function declaration is shown below:
Function SetFormOpacity(WhatForm As MSForms.UserForm, _
Opacity As Byte) As Boolean
Here, WhatForm is a reference to a loaded userform whose opacity you want to modify. The
Opactity parameter is a single byte (with values between 0 and 255) indicating the
level of opacity used for WhatForm. If the value is 255, the form displays in the formal mode,
fully covering the worksheet region behind it. If the value is 0, the form is completely transparent. I would
stronly recommend that you do not set the Opacity to 0.
Images of a userform with varying opacities are shown below:
More Content
This page last updated: