+ Reply to Thread
Results 1 to 3 of 3

Programmatically change a button caption

  1. #1
    quartz
    Guest

    Programmatically change a button caption

    I have an ActiveX button control (entered from the "Control Toolbox") on a
    spreadsheet. I want to programmatically change the caption on the face of the
    button. The macro recorder does not work.

    Could someone please correct my code (below) or provide other code that
    functions? FYI, my code so far:

    Dim ctrlX As OLEObject
    Set ctrlX = ThisWorkbook.ActiveSheet.OLEObjects("CommandButton2")
    ctrlX.Caption = "Click to Enter Date" <<< ERROR HERE!

    Thanks much in advance.


  2. #2
    Tom Ogilvy
    Guest

    Re: Programmatically change a button caption

    Dim ctrlX As OLEObject
    Set ctrlX = ThisWorkbook.ActiveSheet.OLEObjects("CommandButton2")
    ctrlX.Object.Caption = "Click to Enter Date"

    --
    Regards,
    Tom Ogilvy

    "quartz" <[email protected]> wrote in message
    news:[email protected]...
    > I have an ActiveX button control (entered from the "Control Toolbox") on a
    > spreadsheet. I want to programmatically change the caption on the face of

    the
    > button. The macro recorder does not work.
    >
    > Could someone please correct my code (below) or provide other code that
    > functions? FYI, my code so far:
    >
    > Dim ctrlX As OLEObject
    > Set ctrlX = ThisWorkbook.ActiveSheet.OLEObjects("CommandButton2")
    > ctrlX.Caption = "Click to Enter Date" <<< ERROR HERE!
    >
    > Thanks much in advance.
    >




  3. #3
    Jim Thomlinson
    Guest

    RE: Programmatically change a button caption

    It is a lot easier than that...

    sheet1.commandbutton1.caption = "Click to Enter Date"

    You will need to modify this for the sheet and button names, but otherwise
    is should be good to go...

    HTH

    "quartz" wrote:

    > I have an ActiveX button control (entered from the "Control Toolbox") on a
    > spreadsheet. I want to programmatically change the caption on the face of the
    > button. The macro recorder does not work.
    >
    > Could someone please correct my code (below) or provide other code that
    > functions? FYI, my code so far:
    >
    > Dim ctrlX As OLEObject
    > Set ctrlX = ThisWorkbook.ActiveSheet.OLEObjects("CommandButton2")
    > ctrlX.Caption = "Click to Enter Date" <<< ERROR HERE!
    >
    > Thanks much in advance.
    >


+ 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