NigelTufnel
Board Regular
- Joined
- Apr 3, 2008
- Messages
- 53
- Office Version
- 365
- Platform
- 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:
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