+ Reply to Thread
Results 1 to 7 of 7

Commandbutton

  1. #1
    alvin Kuiper
    Guest

    Commandbutton

    Me again

    In VBA i can use Forecolor in the tollbox for a Commandbutton
    But i can't find this in VB for a commandbutton
    If someone know about this, Please Write back
    Remember it is not in VBA But in VB

    Best regards
    Alvin


  2. #2
    Peter T
    Guest

    Re: Commandbutton

    Same way in VB as in VBA, subject to qualifying to Excel.Application

    xlApp.ActiveSheet.OLEObjects("CommandButton1").Object.ForeColor = 255

    Regards,
    Peter


    "alvin Kuiper" <[email protected]> wrote in message
    news:[email protected]...
    > Me again
    >
    > In VBA i can use Forecolor in the tollbox for a Commandbutton
    > But i can't find this in VB for a commandbutton
    > If someone know about this, Please Write back
    > Remember it is not in VBA But in VB
    >
    > Best regards
    > Alvin
    >




  3. #3
    alvin Kuiper
    Guest

    Re: Commandbutton

    Hi
    Nice off you to answer
    But i can't get it to work
    I have see in help and here stand
    that i shall write
    command1.forecolor = something
    but i only get an error en forecolor
    if i write command1. then forecolor don't come foreward as option
    and in my toolbox for the commandbutton i can't see the option
    forecolor, so what to do?

    Best regards
    Alvin


    "Peter T" wrote:

    > Same way in VB as in VBA, subject to qualifying to Excel.Application
    >
    > xlApp.ActiveSheet.OLEObjects("CommandButton1").Object.ForeColor = 255
    >
    > Regards,
    > Peter
    >
    >
    > "alvin Kuiper" <[email protected]> wrote in message
    > news:[email protected]...
    > > Me again
    > >
    > > In VBA i can use Forecolor in the tollbox for a Commandbutton
    > > But i can't find this in VB for a commandbutton
    > > If someone know about this, Please Write back
    > > Remember it is not in VBA But in VB
    > >
    > > Best regards
    > > Alvin
    > >

    >
    >
    >


  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Alvin,

    Prior to VB 6.0 you can't set the ForeColor of CommandButton control.

    Sincerely,
    Leith Ross

  5. #5
    alvin Kuiper
    Guest

    Re: Commandbutton

    Yes
    And thanks for writing

    If you have Vb then make a form, insert a commandbutton
    then show me where to change the color of the text(font)

    Or try to write Command1 (or the name off you sommandbutton)
    and the telle me where to change the text color (forecolor)

    Regards
    Alvin

    "Leith Ross" wrote:

    >
    > Hello Alvin,
    >
    > Prior to VB 6.0 you can't set the ForeColor of CommandButton control.
    >
    > Sincerely,
    > Leith Ross
    >
    >
    > --
    > Leith Ross
    > ------------------------------------------------------------------------
    > Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
    > View this thread: http://www.excelforum.com/showthread...hreadid=488461
    >
    >


  6. #6
    Peter T
    Guest

    Re: Commandbutton

    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.


    "alvin Kuiper" <[email protected]> wrote in message
    news:[email protected]...
    > Hi
    > Nice off you to answer
    > But i can't get it to work
    > I have see in help and here stand
    > that i shall write
    > command1.forecolor = something
    > but i only get an error en forecolor
    > if i write command1. then forecolor don't come foreward as option
    > and in my toolbox for the commandbutton i can't see the option
    > forecolor, so what to do?
    >
    > Best regards
    > Alvin
    >
    >
    > "Peter T" wrote:
    >
    > > Same way in VB as in VBA, subject to qualifying to Excel.Application
    > >
    > > xlApp.ActiveSheet.OLEObjects("CommandButton1").Object.ForeColor = 255
    > >
    > > Regards,
    > > Peter
    > >
    > >
    > > "alvin Kuiper" <[email protected]> wrote in message
    > > news:[email protected]...
    > > > Me again
    > > >
    > > > In VBA i can use Forecolor in the tollbox for a Commandbutton
    > > > But i can't find this in VB for a commandbutton
    > > > If someone know about this, Please Write back
    > > > Remember it is not in VBA But in VB
    > > >
    > > > Best regards
    > > > Alvin
    > > >

    > >
    > >
    > >




  7. #7
    Peter T
    Guest

    Re: Commandbutton

    From Alvin's post a few minutes earlier, I now realise we are not talking
    about a worksheet ActiveX, so ignore all my previous (original mention of
    "toolbox" confused me!).

    Regards,
    Peter T


    "Peter T" <peter_t@discussions> wrote in message
    news:[email protected]...
    > 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.
    >
    >
    > "alvin Kuiper" <[email protected]> wrote in message
    > news:[email protected]...
    > > Hi
    > > Nice off you to answer
    > > But i can't get it to work
    > > I have see in help and here stand
    > > that i shall write
    > > command1.forecolor = something
    > > but i only get an error en forecolor
    > > if i write command1. then forecolor don't come foreward as option
    > > and in my toolbox for the commandbutton i can't see the option
    > > forecolor, so what to do?
    > >
    > > Best regards
    > > Alvin
    > >
    > >
    > > "Peter T" wrote:
    > >
    > > > Same way in VB as in VBA, subject to qualifying to Excel.Application
    > > >
    > > > xlApp.ActiveSheet.OLEObjects("CommandButton1").Object.ForeColor = 255
    > > >
    > > > Regards,
    > > > Peter
    > > >
    > > >
    > > > "alvin Kuiper" <[email protected]> wrote in

    message
    > > > news:[email protected]...
    > > > > Me again
    > > > >
    > > > > In VBA i can use Forecolor in the tollbox for a Commandbutton
    > > > > But i can't find this in VB for a commandbutton
    > > > > If someone know about this, Please Write back
    > > > > Remember it is not in VBA But in VB
    > > > >
    > > > > Best regards
    > > > > Alvin
    > > > >
    > > >
    > > >
    > > >

    >
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1