+ Reply to Thread
Results 1 to 3 of 3

Back color of dynamically-created buttons

  1. #1
    simon
    Guest

    Back color of dynamically-created buttons

    Hi,
    I have created a number of buttons using code which works very
    successfully. The code I've used is as follows:

    'In progress
    With ActiveSheet.Buttons.Add(Left:=l, Top:=t + 20, Width:=60,
    Height:=16)
    .OnAction = "Pro_Hilite"
    .Characters.Text = "In Progress"
    .Name = "cmdProg"
    End With

    (In progress is the name of one of my buttons.)

    If I add in the statement .BackColor = RGB(0, 255, 0),or .BackColor =
    vbRed to this code, then I get an error message saying the object
    doesn't support this property or method.

    My question is: can I change the back color of a button created this
    way and if so how could I do it?

    Many thanks in anticiaption.

    Simon

  2. #2
    Peter T
    Guest

    Re: Back color of dynamically-created buttons

    Hi Simon,

    You can't change the Backcolor of Buttons from the Forms menu, manually or
    programmatically.

    You can change Backcolor of Buttons from the Control's toolbox (view code
    and properties - F4), but you can run into other problems when adding these
    and their code at runtime.

    Regards,
    Peter T



    "simon" <[email protected]> wrote in message
    news:[email protected]...
    > Hi,
    > I have created a number of buttons using code which works very
    > successfully. The code I've used is as follows:
    >
    > 'In progress
    > With ActiveSheet.Buttons.Add(Left:=l, Top:=t + 20, Width:=60,
    > Height:=16)
    > .OnAction = "Pro_Hilite"
    > .Characters.Text = "In Progress"
    > .Name = "cmdProg"
    > End With
    >
    > (In progress is the name of one of my buttons.)
    >
    > If I add in the statement .BackColor = RGB(0, 255, 0),or .BackColor =
    > vbRed to this code, then I get an error message saying the object
    > doesn't support this property or method.
    >
    > My question is: can I change the back color of a button created this
    > way and if so how could I do it?
    >
    > Many thanks in anticiaption.
    >
    > Simon




  3. #3
    Peter T
    Guest

    Re: Back color of dynamically-created buttons

    Forgot to suggest - to simulate a coloured button look at AutoShapes > Basic
    Shapes and the one that looks like a double rectangle. Format line to "No
    Line" and colour as required. Add text and assign macro. Record a macro for
    ideas on how to code.

    Regards,
    Peter T

    "Peter T" <peter_t@discussions> wrote in message
    news:#[email protected]...
    > Hi Simon,
    >
    > You can't change the Backcolor of Buttons from the Forms menu, manually or
    > programmatically.
    >
    > You can change Backcolor of Buttons from the Control's toolbox (view code
    > and properties - F4), but you can run into other problems when adding

    these
    > and their code at runtime.
    >
    > Regards,
    > Peter T
    >
    >
    >
    > "simon" <[email protected]> wrote in message
    > news:[email protected]...
    > > Hi,
    > > I have created a number of buttons using code which works very
    > > successfully. The code I've used is as follows:
    > >
    > > 'In progress
    > > With ActiveSheet.Buttons.Add(Left:=l, Top:=t + 20, Width:=60,
    > > Height:=16)
    > > .OnAction = "Pro_Hilite"
    > > .Characters.Text = "In Progress"
    > > .Name = "cmdProg"
    > > End With
    > >
    > > (In progress is the name of one of my buttons.)
    > >
    > > If I add in the statement .BackColor = RGB(0, 255, 0),or .BackColor =
    > > vbRed to this code, then I get an error message saying the object
    > > doesn't support this property or method.
    > >
    > > My question is: can I change the back color of a button created this
    > > way and if so how could I do it?
    > >
    > > Many thanks in anticiaption.
    > >
    > > Simon

    >
    >




+ 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