我正在使用 VBA 生成包含 ActiveX 表单控件的 Excel 工作表。然而,可用于对象属性的文档相当粗略。我注意到,例如,当我创建一个 OptionButton 控件时,该对象包含一个纯白色边框。我可以手动进入设计模式;右键点击; “格式化对象”,然后在对话框的“颜色和线条”选项卡下,将填充(自动)更改为“无填充”。请参见以下示例:
但是我还没有弄清楚如何通过代码来做到这一点。请参阅以下内容:
Dim sht as Sheet
Set sht = [WorkbookObject].Sheets(1)
With sht
.OLEObjects.Add(ClassType:="Forms.OptionButton.1", Left:=4.5, Top:=34.5, Width:=105, Height:=15).Name = "RadioB_1"
With .OLEObjects("RadioB_1").Object
.Caption = "First Option"
.GroupName = "ColumnFilter"
.BackColor = RGB (128, 128, 128)
.BackStyle = 1
End With
' The above all works fine, however I can't find the correct property
' for the border fill. I have tried various properties for
' .OLEObjects("RadioB_1") and for .OLEObjects("RadioB_1").Object
' however I can't find the correct property.
End With
Excel 的对象浏览器并没有给我太多线索。
我还查看了 MSDN 关于 OLE Object Properties 的文章,但是似乎没有任何东西可以解决我的需要。