ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   change caption font color at runtime (https://www.excelbanter.com/excel-programming/290371-change-caption-font-color-runtime.html)

gkelle[_3_]

change caption font color at runtime
 
The following code creates checkboxes on a form at runtime
I'm trying to change the font color of the caption

For iColumn = constStartColumn To i_NUMCOLUMNS
Set ctlMyControl = frmEditPartVolume!
frWhereUsed.Controls.Add("Forms.CheckBox.1")
Next iColumn

iLeft = iHorizSpacing
iTop = iVertSpacing

iTotalControls = frmEditPartVolume!frWhereUsed.Controls.Count
iColumn = constStartColumn
For Each ctlMyControl In frmEditPartVolume!frWhereUsed.Controls
ctlMyControl.Caption = Worksheets("Part List").Cells(10,
iColumn)
ctlMyControl.Left = iLeft
ctlMyControl.Height = iCheckBoxHeight
ctlMyControl.Font.Size = 8.25
crashes at this point
ctlMyControl.Font.ColorIndex = 3

ctlMyControl.AutoSize = True


---
Message posted from http://www.ExcelForum.com/


Tom Ogilvy

change caption font color at runtime
 
ActiveX controls don't have a colorindex property.

ctlMyControl.forecolor = vbRed

--
Regards,
Tom Ogilvy

"gkelle " wrote in message
...
The following code creates checkboxes on a form at runtime
I'm trying to change the font color of the caption

For iColumn = constStartColumn To i_NUMCOLUMNS
Set ctlMyControl = frmEditPartVolume!
frWhereUsed.Controls.Add("Forms.CheckBox.1")
Next iColumn

iLeft = iHorizSpacing
iTop = iVertSpacing

iTotalControls = frmEditPartVolume!frWhereUsed.Controls.Count
iColumn = constStartColumn
For Each ctlMyControl In frmEditPartVolume!frWhereUsed.Controls
ctlMyControl.Caption = Worksheets("Part List").Cells(10,
iColumn)
ctlMyControl.Left = iLeft
ctlMyControl.Height = iCheckBoxHeight
ctlMyControl.Font.Size = 8.25
crashes at this point
ctlMyControl.Font.ColorIndex = 3

ctlMyControl.AutoSize = True


---
Message posted from http://www.ExcelForum.com/




gkelle[_4_]

change caption font color at runtime
 
Thanks, That work

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 10:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com