Here are instructions for that which I found somwhere on the Web a couple of
years ago (my apologies to the actual author). I have added a few notes of my
own.
This code makes an userform semitransparent. Works equally well for Word or
Excel. Place the following controls on an Userform.
• CommandButton1
• ScrollBar1
• Label1
Copy & paste all the code below into the form's code page.
Please note, the userform will be invisible if you move the scroll bar to
100%. That means you cannot control the userform any more. I suggest setting the
scrollbar limits to Min value = 2 and Max value = 98. Double-clicking the
userform or the label resets the scrollbar value to 50.
Private Declare Function GetActiveWindow Lib "USER32" () As Long
Private Declare Function SetWindowLong Lib "USER32" _
Alias "SetWindowLongA" ( _
ByVal hWnd As Long, ByVal lngWinIdx As Long, _
ByVal dwNewLong As Long) As Long
Private Declare Function GetWindowLong Lib "USER32" _
Alias "GetWindowLongA" ( _
ByVal hWnd As Long, ByVal lngWinIdx As Long) As Long
Private Declare Function SetLayeredWindowAttributes Lib "USER32" ( _
ByVal hWnd As Long, ByVal crKey As Integer, _
ByVal bAlpha As Integer, ByVal dwFlags As Long) As Long
Private Const WS_EX_LAYERED = &H80000
Private Const LWA_COLORKEY = &H1
Private Const LWA_ALPHA = &H2
Private Const GWL_EXSTYLE = &HFFEC
Dim hWnd As Long
Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub ScrollBar1_Change()
Call Semitransparent(Me.ScrollBar1.Value)
End Sub
Private Sub UserForm_Activate()
Me.ScrollBar1.Value = 50
End Sub
Private Sub Label1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Me.ScrollBar1.Value = 50
End Sub
Private Sub UserForm_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Me.ScrollBar1.Value = 50
End Sub
Private Sub Semitransparent(ByVal intLevel As Integer)
Dim lngWinIdx As Long
hWnd = GetActiveWindow
lngWinIdx = GetWindowLong(hWnd, GWL_EXSTYLE)
SetWindowLong hWnd, GWL_EXSTYLE, lngWinIdx Or WS_EX_LAYERED
SetLayeredWindowAttributes hWnd, 0, (255 * intLevel) / 100, LWA_ALPHA
Label1.Caption = "Semitransparent level is ..." & (100 - intLevel) & "%"
End Sub