ActiveX Check Boxes Losing Border when clicked

NigelTufnel

Board Regular
Joined
Apr 3, 2008
Messages
53
Office Version
  1. 365
Platform
  1. Windows
I have some VBA code that creates a series of ActiveX checkboxes on a worksheet and then formats them. Each checkbox has a light yellow background and a black border around it.

The code creates the boxes successfully, but after running the code, when I click on a box to check/uncheck it, the border of the box disappears when the box receives the focus. After I click on something else on the sheet, the border re-appears.

When I've used the FORMS checkbox, I've never had this problem. Although this problem is minor in the grand scheme of things, it's distracting for my users. Can anyone suggest how I can fix this?

Am I using the wrong kind of object for the border? I have to admit, I get very confused by the OLEObject / Object / ShapeRange / etc. logic and syntax.

Thanks for any help.

In the event it helps, here is a snippet of the code that creates the boxes:

Code:
Set oBox = ActiveSheet.OLEObjects.Add(classType:="Forms.CheckBox.1", Link:=False, _
               DisplayAsIcon:=False, Left:=rSCBoxLoc.Left, Top:=rSCBoxLoc.Top, Width:=cBoxWidth, _
               Height:=cBoxHeight)
With oBox
   .Name = sNamePrefix & "SCBox" & iCount
   .LinkedCell = rLinkedCell.Offset(iCount - 1, 0).Address
   .Object.Caption = rBoxText.Offset(iCount, 0)
   .Object.Value = True
   .Object.BackColor = RGB(255, 255, 204) 
   .Object.BackStyle = fmBackStyleOpaque
End With

With oBox.ShapeRange.Line
  .Weight = 0.75
  .DashStyle = msoLineSolid
  .Style = msoLineSingle
  .Visible = msoTrue
  .ForeColor.SchemeColor = 8
  .BackColor.RGB = RGB(255, 255, 255)
End With
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

Forum statistics

Threads
1,224,599
Messages
6,179,827
Members
452,946
Latest member
JoseDavid

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top