Transparent commandbutton that refuses to stay transparent??

kbishop94

Active Member
Joined
Dec 5, 2016
Messages
296
Code:
Private Sub cmdRosenbergElCampo_Click()

If cmdRosenbergElCampo.Caption = "EL-CAMPO" Then

Worksheets("Current").cmdRosenbergElCampo.Caption = "ROSENBERG"
Worksheets("Current").cmdRosenbergElCampo.BackStyle = BackStyleTransparent

Call Macro3

Else
   
Worksheets("Current").cmdRosenbergElCampo.Caption = "EL-CAMPO"
Worksheets("Current").cmdRosenbergElCampo.BackStyle = BackStyleTransparent

Call Macro4

End If
Worksheets("Current").cmdRosenbergElCampo.BackStyle = BackStyleTransparent

End Sub

Thats the code for the commandbutton that under its properties on the worksheet its set to transparent ( and is transparent) but when its executed it changes to the standard grey color.

This is an activeX control, btw

Here is the other code (for Macro3 listed in the code above):

Code:
Sub Macro3()

    ' button for ROSENBERG EMPLOYEES
    
ActiveWindow.ScrollColumn = 1

Dim lCol As Long
    lCol = ActiveSheet.UsedRange.Columns.Count
    rCol = ActiveSheet.UsedRange.Rows.Count
    For Each Cell In Range(Cells(5, 6), Cells(5, lCol))

If Cell = "R" Then Columns(Cell.Column).Hidden = False Else Columns(Cell.Column).Hidden = True
Next

Range(Cells(1, 2), Cells(rCol, lCol)).Interior.Color = xlNone
Range(Cells(1, 2), Cells(rCol, lCol)).Font.Color = vbBlack
Range(Cells(1, 2), Cells(rCol, lCol)).Font.Bold = False
Range(Cells(1, 2), Cells(rCol, lCol)).Borders.Weight = xlThin

Range("B6").Font.Color = &HFF&
Range("B6").Font.Bold = True
Range("B6").Borders.Weight = xlMedium

Range("B2:B4").Font.Color = &HC000&
Range("B2:B4").Font.Bold = True
Range("B2:B4").Borders.Weight = xlThin

Worksheets("Current").cmdRosenbergElCampo.BackStyle = BackStyleTransparent

End Sub
Macro4 (the other event that is linked in the first code) is identical to macro3, btw


I went back in under both codes and added the "BackStyle = BackStyleTransparent" code which had no effect btw. :confused:

Is this a known issue, or do I just have something funky in my code that I'm just not seeing?

Thanks
 
Last edited:

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
33,806
Office Version
365
Platform
Windows
Not perfect but
Code:
Private Sub CommandButton1_Click()
Me.CommandButton1.TakeFocuson click= False
End Sub
will make it transparent once the cursor is moved off the button
Ignore the space between on & click, its only there to prevent the board turning it into ***
 
Last edited:

kbishop94

Active Member
Joined
Dec 5, 2016
Messages
296
Not perfect but
Code:
Private Sub CommandButton1_Click()
Me.CommandButton1.TakeFocuson click= False
End Sub
will make it transparent once the cursor is moved off the button
Ignore the space between on & click, its only there to prevent the board turning it into ***
Awesome! I was really thinking that it was a glitch in excel and I wasnt going to be able to 'fix' it. THat did the trick. No biggie that its black until you move the cursor... i can live with that.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
33,806
Office Version
365
Platform
Windows
Glad to help & thanks for the feedback
 

Jaafar Tribak

Well-known Member
Joined
Dec 5, 2002
Messages
7,561
Office Version
2016
Platform
Windows
Awesome! I was really thinking that it was a glitch in excel and I wasnt going to be able to 'fix' it. THat did the trick. No biggie that its black until you move the cursor... i can live with that.
Or you could do this :
Code:
Private Sub CommandButton1_Click()
    CommandButton1.Visible = False
    CommandButton1.Visible = True
End Sub
 

kbishop94

Active Member
Joined
Dec 5, 2016
Messages
296
Just now saw this...

this is even better (doesnt temporarily make the button black until the cursor loses focus.) . THanks Jaafar.
 

Forum statistics

Threads
1,085,714
Messages
5,385,411
Members
401,943
Latest member
xvpnkr

Some videos you may like

This Week's Hot Topics

Top