lundi 16 juillet 2018

Green Oki check boxes in Excel

my aim is to get the green signs next to the Buttons (I have uploaded an Image of it) a la VBA in Excel. The green signs have to appear every time the macro of the first button (commandbutton1) has finished running successfully. I am a bit of an amateur when it comes to VBA.

My effort yields this:

enter image description here

My aim is this:

enter image description here

Codes in the workbook:

 Option Explicit

 Private Sub Workbook_Open()
 Call Tabelle1("Tabelle1").prcResetLabels
 End Sub

In the tabelbook:

  Option Explicit

  Private Sub CheckBox1_Click()
  Call prcSetLabel(probjLabel:=Label1)
  End Sub

  Private Sub prcSetLabel(ByRef probjLabel As MSForms.Label)
  With probjLabel
 .Caption = "P"
 .TextAlign = fmTextAlignCenter
 .SpecialEffect = fmSpecialEffectSunken
 .ForeColor = &H1DF3A
  With .Font
 .Name = "Wingdings 2"
 .Size = 20
  End With
  End With
  End Sub

  Friend Sub prcResetLabels()
  Dim objOLEObject As OLEObject
  For Each objOLEObject In OLEObjects
  With objOLEObject
  If .progID = "Forms.Label.1" Then _
  .Object.Caption = vbNullString
  End With
  Next
  Call ThisWorkbook.Save
  End Sub

1.) Caution: The error Msg. states: The variable Label1 is not defined.

2.) I also dont know what activx element to use for the check box.

any help would be appreciated. Thank you




Aucun commentaire:

Enregistrer un commentaire