Loading
Ozgrid Excel Help & Best Practices Forums

Excel Video Tutorials / Excel Dashboards Reports



Page 1 of 2 1 2 LastLast
Results 1 to 10 of 16

Thread: Rename Command Button

  1. #1
    Join Date
    18th March 2008
    Posts
    7

    Rename Command Button

    I'm having a problem with some of the command buttons in a dynamic spread sheet that I am creating. I add the command button to the page and it has the name "commandbutton1" I would like to rename it to something more meaningful. When I rename the button and then loop through the buttons on the page and try to match the name it doesn't work. I put in a message box to see what names it is pulling back and it for some reason keeps pulling back "commandbutton1" even after I updated the name property.

    Anyone have any ideas on what is causing this issue?

    Thanks
    Troy

    Excel Video Tutorials / Excel Dashboards Reports


  2. #2
    Join Date
    14th July 2004
    Posts
    10,539

    Re: Renaming Command Button

    Troy

    How have you tried this?

    And how are you (in fact why are you) creating the buttons dynamically?

    ADDED BY ADMIN

    To name CommandButton ( ActiveX From Control Toolbox )

    Right click on the button and choose Properties and edit (Name).

    To name aButton ( NOT ActiveX From Forms Toolbar )

    Select the button and type a new name in the Name Box (left of the Formula Bar) and then Enter.
    Last edited by Dave Hawley; March 18th, 2008 at 11:08.
    Boo!

  3. #3
    Join Date
    17th July 2004
    Location
    Texas, USA
    Posts
    1,939

    Re: Renaming Command Button

    Welcome to ozgrid

    Are you “re-naming” the Name property or perhaps the Caption property?

    Are these activeX buttons on the worksheet?
    Bill
    Tip: To avoid chasing code always use Option Explicit.

  4. #4
    Join Date
    18th March 2008
    Posts
    7

    Re: Renaming Command Button

    Sorry I miss spoke the spread sheet is being created to collect dynamic data. The pages have a preset layout with command buttons.

    I think it has something to do with the length of the name. Is there a char limit on the name of the buttons? I tried a shorter name and it changed the name.

    Thanks
    Troy
    Auto Merged Post Until 24 Hrs Passes;

    Yes I am renaming the name property not the caption.

    Not sure if they are activeX buttons. I inherited the spread sheet and I'm updating it. I know they are not marco buttons if that makes a difference and they have onclick properties.

    Thanks
    Troy
    Last edited by trichard0987; March 18th, 2008 at 02:39. Reason: Auto Merged Doublepost

    Excel Video Tutorials / Excel Dashboards Reports


  5. #5
    Join Date
    17th July 2004
    Location
    Texas, USA
    Posts
    1,939

    Re: Renaming Command Button

    They must be activeX if the name is “Commandbutton1”. Buttons of the Forms menu are named “Button 1”.

    Will guess what. I did a test and the name change failed when I added character 129 (Starting with a one character name). Are your names longer than that? I can’t imagine why they would be.
    Bill
    Tip: To avoid chasing code always use Option Explicit.

  6. #6
    Join Date
    18th March 2008
    Posts
    7

    Re: Renaming Command Button

    Nope only 35 chars ExportMaterialTransferButton worked but ExportMaterialTransferReportButton did not. It didn't throw an error and it shows it renamed it but when I loop through the controls on the sheet the name hadn't changed.

    Excel Video Tutorials / Excel Dashboards Reports


  7. #7
    Join Date
    17th July 2004
    Location
    Texas, USA
    Posts
    1,939

    Re: Renaming Command Button

    I have no problem naming a n activex button on a sheet "ExportMaterialTransferReportButton".

    Can you please post a sample
    Bill
    Tip: To avoid chasing code always use Option Explicit.

  8. #8
    Join Date
    18th March 2008
    Posts
    7

    Re: Renaming Command Button

    I have a work book with 9 sheets and I want to have on sheet that will export all the data from the other sheets so I have a button on that first sheet that will export all sheets and when I put this code under the button click event and execute it the name of the button I changed on one of the other sheet is not getting saved and it displays the old button name.

    Not sure if that made sense but let me know.

    VB:
    Private Sub ExportEntireReportButton_Click() 
        Dim wsheet As Worksheet 
         
         'Loop through all Worksheets
        For Each wsheet In Worksheets 
             
             'MsgBox (wsheet.Name)
             
             ' Select current sheet.
            Sheets(wsheet.Name).Select 
             
            Dim OleObj As OLEObject 
             
             ' Loop through each object on the sheet.
            For Each OleObj In wsheet.OLEObjects 
                 '****************************************
                MsgBox OleObj.Name ' This gets the name of the object
                 '****************************************
                 
            Next OleObj 
        Next wsheet 
    End Sub 
    
    

    Excel Video Tutorials / Excel Dashboards Reports


  9. #9
    Join Date
    17th July 2004
    Location
    Texas, USA
    Posts
    1,939

    Re: Renaming Command Button

    You have posted code that displays the name of the objects.

    Were is the code that you attempt to change the name?? That’s what we need to see.
    Bill
    Tip: To avoid chasing code always use Option Explicit.

  10. #10
    Join Date
    14th July 2004
    Posts
    10,539

    Re: Renaming Command Button

    Troy

    Bill's right - we don't need to see code that loops through and display button names.

    And it also might be helpful if you actually clarified what you are doing in the first place.

    I was pretty confused by your earlier post, but that's not unusual.

    Why are you dynamically creating these buttons?

    Why do you need to rename them?
    Boo!

Thread Information

Users Browsing this Thread

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

Possible Answers

  1. Run Command Button Click From Another Command Button
    By ExcelJunkie in forum EXCEL HELP
    Replies: 11
    Last Post: January 1st, 2014, 23:02
  2. Toolbar Command Button As Toggle Button
    By rossfourfive in forum EXCEL HELP
    Replies: 8
    Last Post: August 19th, 2008, 05:53
  3. Rename Custom Toolbar Button
    By RowanS in forum EXCEL HELP
    Replies: 2
    Last Post: April 20th, 2007, 18:37
  4. Replies: 2
    Last Post: October 5th, 2006, 15:47
  5. Replies: 6
    Last Post: January 13th, 2006, 18:11

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
  •  
porno