+ Reply to Thread
Results 1 to 6 of 6

Form button question

  1. #1
    Bri
    Guest

    Form button question

    hi

    Is the Name of a form button the same as the Caption ON the button???
    Unlike with command buttons from the control toolbox , I can't seem to see a
    Properties window for form buttons. Where is it?

    Thanks,
    bri





  2. #2
    Ken Johnson
    Guest

    Re: Form button question

    Hi Bri,
    The Name and captions are not the same.
    Say you place a Forms button on a sheet, its automatic name is what
    appears in the Name box on the right side of the Formula bar, eg Button
    1.
    The automatic caption is also Button 1.
    The name can be changed by selecting the button with a right click,
    clicking in the Name box, editing the name, then clicking Enter.
    The caption can be changed by selecting the button with a right click,
    selecting Edit text from the contextual menu, editing the text, then
    clicking on the sheet.
    In your code, if you need to return the caption on a button (say
    button Name = Button 1) that is on the ActiveSheet, you can Dim a
    String variable for storing the caption, Dim a Shape object, set the
    Shape object to be the required button then reference as below..

    Dim strCaption as String
    Dim MyButton as Shape
    Set MyButton = ActiveSheet.Shapes("Button 1")
    strCaption = MyButton.TextFrame.Characters.Text

    If you have a number of buttons on a sheet which all run the same macro
    you might want to determine in your code which button the user pressed.
    The name of that button is returned by Application.Caller eg...

    If Application.Caller = "Button 1" then...


    Ken Johnson


  3. #3
    Bri
    Guest

    Re: Form button question

    thank you, Ken
    bri



  4. #4
    Ken Johnson
    Guest

    Re: Form button question

    You're welcome Bri.
    Thanks for the feedback.
    Ken Johnson


  5. #5
    Tom Ogilvy
    Guest

    Re: Form button question

    msgbox Activesheet.Buttons("Button 1").Caption

    or

    msgbox Activesheet.Buttons("Button 1").Name

    Activesheets.buttons("Button 1").Caption = "ABC"

    Dim Btn as Button
    set btn = Activesheet.Buttons(application.Caller)
    msgbox btn.name & " - " & btn.Caption

    would be more direct and easier to use.

    --
    Regards,
    Tom Ogilvy


    "Ken Johnson" <[email protected]> wrote in message
    news:[email protected]...
    > You're welcome Bri.
    > Thanks for the feedback.
    > Ken Johnson
    >




  6. #6
    Ken Johnson
    Guest

    Re: Form button question

    Hi Tom,
    I was using the Object Browser as a guide. I guess a Forms button
    equates to a CommandBar button, which has the caption property.

    Thanks again Tom.

    Ken Johnson


+ 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