PDA

View Full Version : Allow user to set Button Caption



Djblois
05-16-2007, 08:49 AM
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:

SaveSetting "Business Reporting Today", stgQckRptNum, "Report Name", UserQuickReports.ReportName

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.

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

thank you for the help.

Tommy
05-16-2007, 09:22 AM
Hi Djblois,

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

HTH

Simon Lloyd
05-16-2007, 09:24 AM
How about:

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

Djblois
05-16-2007, 09:26 AM
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".

Djblois
05-16-2007, 09:44 AM
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

GetSetting("Business Reporting Today", "StartQuick1", "Report Name")

what you did is the same as:

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

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.

Tommy
05-16-2007, 10:18 AM
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. :)