Consulting

Results 1 to 6 of 6

Thread: Allow user to set Button Caption

  1. #1
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,091
    Location

    Allow user to set Button Caption

    I am now trying to get where a user can set up their own Quick Reports (Commonly used reports that use the same exact options ) and save it to a button. I have no trouble with the saving and using the settings for the quick reports but I can't find a way to get the user to save the name of caption for the button.

    Here is what I thought would work:

    [VBA]SaveSetting "Business Reporting Today", stgQckRptNum, "Report Name", UserQuickReports.ReportName[/VBA]

    and then I delete the toolbar and readd the tool bar, which I have no problem with but the caption of the Quick Report Button always comes up as Quick Report 1.

    [VBA]Set subMenuItem = MenuItem.Controls.Add(Type:=msoControlButton)
    subMenuItem.OnAction = "StartQuick1"
    subMenuItem.Caption = GetSetting("Business Reporting Today", "StartQuick1", "Report Name", "Quick Report 1")[/VBA]

    thank you for the help.

  2. #2
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    Hi Djblois,

    What is stgQckRptNum? if it doesn't equal "StartQuick1" there is the problem.

    HTH

  3. #3
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    How about:
    [VBA]
    Dim T1 As Variant
    T1 = InputBox("Enter Report Button Name", "Button Caption")
    Set subMenuItem = MenuItem.Controls.Add(Type:=msoControlButton)
    subMenuItem.OnAction = "StartQuick1"
    subMenuItem.Caption = GetSetting("Business Reporting Today", "StartQuick1", "Report Name", T1)
    End Sub
    [/VBA]
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  4. #4
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,091
    Location
    sorry tommy. I forgot that was there, it is an argument that I set when I call the sub, so I can create multiple Quick Report Buttons, all using the same code. That argument is set to "StartQuick1".

  5. #5
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,091
    Location
    but Simon Where you put the T1 is the default, that is the number it is supposed to use if the user hasn't set the name for the report yet. It is supposed to use the setting in

    [VBA]GetSetting("Business Reporting Today", "StartQuick1", "Report Name")[/VBA]

    what you did is the same as:

    [VBA]T1 = InputBox("Enter Report Button Name", "Button Caption")
    Set subMenuItem = MenuItem.Controls.Add(Type:=msoControlButton)
    subMenuItem.OnAction = "StartQuick1"
    subMenuItem.Caption = T1[/VBA]

    There is no need to use the settings than. The problem with your way is when a user updates the add-in the will have to rename the report.

  6. #6
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    Then the only other option is UserQuickReports.ReportName does not contain the correct name? Check where this is set, or where it is supposed to be.

Posting Permissions

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