Label change color when clicked

前端 未结 2 589
南旧
南旧 2021-01-15 18:53

I have a VBA/Excel that user clicks on labels (Active X - Text Label) to perform some actions. The label property is BackStyle Transparent, but when the user click, the labe

2条回答
  •  耶瑟儿~
    2021-01-15 19:42

    Don't use an ActiveX control for this. Any Shape can be assigned to a macro, so instead of having Click event handlers for ActiveX labels like so:

    Private Sub Label2_Click()
        'do stuff
    End Sub
    

    Make the handlers public, give them a meaningful name:

    Public Sub BuscaPorPalavraChave()
        'do stuff
    End Sub
    

    Replace the labels with TextBox shapes - make the shape fill and border transparent, right-click the shape, and select "assign macro" - then pick BuscaPorPalavraChavre. Done!

    textbox shape made to look just like a label

    Rinse & Repeat for every label. I know, painful - but worth it!

    That navigation UI looks very nice BTW =)

提交回复
热议问题