Alvin,
I don't know why my previous suggestion doesn't work for you.
In your VB try
Dim objOLE As OLEObject
Dim sName As String
Set objOLE= xlApp.ActiveSheet.OLEObjects.Add _
(ClassType:="Forms.CommandButton.1", _
Left:=40, Top:=40, _
Width:=150, Height:=30)
sName = objOLE.Name
MsgBox sName, vbMsgBoxSetForeground
xlApp.ActiveSheet.OLEObjects(sName).object.ForeColor = 128
' assumes xlApp is a reference to Excel.Application
You may also be able to do
xlApp.ActiveSheet.CommandButton1.ForeColor = 128
Though, depending on what you are doing, this might cause problems in some
scenarios (eg if you have just added the control even if you can be sure of
what its name will be).
Leith,
I only have VB6 but I'm curious as to why the above would not work in
earlier versions, it's an Excel method, assuming we are talking about a
worksheet ActiveX.
FWIW it works with VB6 to xl97
Regards,
Peter T
PS for Alvin - you may not have noticed, in your earlier thread today you
have been asked to clarify how you solved your problem. Presumably not using
the method suggested in response to your question, hence the interest.