PDA

View Full Version : Solved: transparent command button vba



numcrun
10-16-2010, 03:17 AM
When I create a command button manually and set it as transparent it is. But the code below does not make it transparent, even though the properties say it is.


Private Sub Worksheet_Activate()

Set obj = ActiveSheet.OLEObjects.Add(ClassType:="Forms.CommandButton.1", _
Link:=False, DisplayAsIcon:=False, Left:=307, Top:=80, Width:=40, Height:=40)
obj.Name = "CommandButton1"
ActiveSheet.OLEObjects("CommandButton1").Object.BackStyle = fmBackStyleTransparent
ActiveSheet.OLEObjects("CommandButton1").Object.Caption = ""

End Sub

p45cal
10-17-2010, 04:20 PM
try:
With ActiveSheet.OLEObjects.Add(ClassType:="Forms.CommandButton.1", _
Link:=False, DisplayAsIcon:=False, Left:=307, Top:=80, Width:=40, Height:=40)
.Name = "CommandButton1"
.Object.BackStyle = fmBackStyleTransparent
.Object.Caption = ""
.ShapeRange.Fill.Transparency = 1#
End With

numcrun
10-17-2010, 05:08 PM
Thanks very much, that's the one!