I use the below code for formatting a bunch of command buttons.
Private Sub fmtCmdBtn(ByVal obj As commandbutton, msg As String, fillcolor, txtcolor As Double)
.Caption = msg
.BackColor = fillcolor
.ForeColor = txtcolor
There are no errors when I use :
fmtCmdBtn btnTest1 "Test" Vbred, vbwhite ' where btnTest1 is the name of the command button
However, I get a Type Mismatch error when I substitute a variable for the object.
Dim myobj as Object ' Tried Symbol also with same error
Set myobj = ThisDisplay.Symbols.Item(6)
Set myobj= ThisDisplay.Symbols("btnTest1")
fmtCmdBtn myobj "Test" Vbred, vbwhite
Substituting the name of the button with a variable throws up Type mismatch error. What am I doing wrong? Any help appreciated. Thanks in advance.