Set Userform Transparency(Opacity) With Slider

            Transparency of userform can be set easily with slider control and VBA codes.

excel userform transparency

VBA codes to set userform opacity:
Private Sub Sliderk_Scroll()
    Call SetOneValueSlider
End Sub

Private Sub SetOneValueSlider()
   Dim bytOpacity As Byte

bytOpacity = Sliderk.Value
hWnd = FindWindow("ThunderDFrame", Me.Caption)
Call SetWindowLong(Me.hWnd, GWL_EXSTYLE, GetWindowLong(Me.hWnd, GWL_EXSTYLE) Or WS_EX_LAYERED)
Call SetLayeredWindowAttributes(Me.hWnd, 0, bytOpacity, LWA_ALPHA)
    Label1.Caption = Sliderk.Value
End Sub

excel vba slider control

No comments:

Post a Comment