I'm trying to create an ActiveX label on my worksheet and at certain times have it be transparent.
Here's my code so far:
Sub CreateButton()
Dim menuxBx As MSForms.Label
ActiveSheet.Select
Set menuxBx = ActiveSheet.OLEObjects.Add(ClassType:="Forms.Label.1", _
Link:=False, DisplayAsIcon:=False, Left:=200, Top:=100, Width:=100, Height:=35).Object
With menuxBx
.BackStyle = 0
.Name = "MouseOverBX"
.Visible = True
.caption = "Test"
End With
End Sub
This creates the label just fine, and so far as I can tell, can manipulate any other properties I'd desire to put inside the "With" loop. Except I can't get the .BackStyle property to work. If I manually create the label on the sheet, I can set the BackStyle property from the properties window and the label immediately becomes see-through. But even if I take that line out of my code and just create the label, if I try to change the property in the properties window, it will change to transparent, but the label remains opaque. The .BackStyle line in my code will set the property to transparent, but the label remains opaque. I've tried adding this so that it changes this property at run time:
Private Sub MouseOverBX_Click()
Me.MouseOverBX.BackStyle = 0
End Sub
(in the worksheet module) - no dice.
I've read a lot of forums where people respond, asking, "Why not use some other object?" or "Do you really need to use an ActiveX object?" I'm not looking for those kinds of responses. I'm really just looking for an explanation of this phenomenon. I'm using the ActiveX label because I need it to support a MouseOver event. I know I can achieve this same result with shapes and other such, but I'm trying to preserve the functionality of other parts of my code as much as possible, and already know about those other suggestions.
Your macro can be amended as follows...