BusinessObjects Board

Button grayed in toolbar

Hi,

I’m using that VBA code that I’ve found searching the forum :


Sub LoadToolbar()
Dim gbtnTool As CmdBarControl
Dim GToolbar As CmdBar
Set GToolbar = Application.CmdBars.Add("CountryState", boBarLeft)
GToolbar.Visible = True
GToolbar.Enabled = True
Set gbtnTool = GToolbar.Controls.Add(boControlButton)
With gbtnTool
  .Caption = "Get Revenue"
  .DescriptionText = "Get Revenue from Country and State"
  .TooltipText = "View revenue for Country and State"
  .OnAction = "ThisDocument.ShowPromptWindow"
  Application.Clipboard.Clear
  If Dir(ThisDocument.Path &amp; "\ICO.BMP") <> "" Then
    Application.Clipboard.SetData LoadPicture(ThisDocument.Path &amp; "\ICO.BMP"), 2
    .PasteFace
    Application.Clipboard.Clear
  End If
End With
End Sub

and I’ve put it in the Document_Open of my add-in.
But the button is always grayed and can’t be pushed, the bitmap don’t really look like mine but the description is good. Why?


Toby :fr: (BOB member since 2005-10-28)

The problem is in this line:

.OnAction = "ThisDocument.ShowPromptWindow"

ThisDocument references a Reporter document, not a VBA module. If you want to reference the ShowPromptWindow procedure in the currently active document, just put the name of the procedure with no other qualifier. Like this:

.OnAction = "ShowPromptWindow"

Dwayne Hoffpauir :us: (BOB member since 2002-09-19)

It’s still grayed :frowning:

but this code is the code in ThisDocument (… .rea), in the Document_Open, because I want the icon to appear on the startup of BO, indeed when the add-in is opening.
Am i wrong doing that?


Toby :fr: (BOB member since 2005-10-28)

My apologies … I missed the fact that it was an add-in. You need the add-in filename as a qualifier. The syntax is like this:

.OnAction = "YourAddin.rea!ShowPromptWindow"

Now the button should be active regardless of the active document.


Dwayne Hoffpauir :us: (BOB member since 2002-09-19)

Thank you for your help Dwayne, your answers have help me to understand and find a solution :
Here the code in ThisDocument :


Sub ShowPromptForm()
PromptForm.Show
End Sub

Private Sub Document_Open()
Call LoadToolbar
End Sub

...

Sub LoadToolbar()
Dim gbtnTool As CmdBarControl
Dim GToolbar As CmdBar
...
  .OnAction = "MyAddIn.rea!ThisDocument.ShowPromptForm"

...
End Sub

and it seems to work well :slight_smile: except the icon is really ugly… even in 16 colors…

I can’t call PromptForm.Show in the OnAction.


Toby :fr: (BOB member since 2005-10-28)

Well, I can’t help with “ugly” icons I’m afraid :lol: . I can make a suggestion on how to use them though. If you put the icon on the userform itself, you can use it as the source for the toolbar icon. It will save you from having to distribute the icon separately, depend on a certain location, etc. Look at the code in this utility for an example.


Dwayne Hoffpauir :us: (BOB member since 2002-09-19)

Oh that’s yours, it’s an honor :slight_smile:

It’s seems to be very useful, and in my case i m sure it would be!
I’ve try to use it but when I click the checkbox next to DataProviderUtilities and click Ok I ve got an error like that

You haven’t rights to access that document (FRM0008)

Something like that cause in my case it s in french :wink:


Toby :fr: (BOB member since 2005-10-28)

The relevant lines are here:

Application.Clipboard.SetData CopyDataProviderForm.Image1.Picture
Button.PasteFace

CopyDataProviderForm is the userform name.
Image1 is the object on that userform.
Button is the object that represents the menu item.


Dwayne Hoffpauir :us: (BOB member since 2002-09-19)

Ok! thank you very much for all that details :slight_smile:

It’s another problem but any idea of why I can’t use you add-in? (BO 6.5.1 stand alone)


Toby :fr: (BOB member since 2005-10-28)

Not a clue. Almost 1500 downloads, and I haven’t heard of that issue.


Dwayne Hoffpauir :us: (BOB member since 2002-09-19)

I’ve got the same error with add-ins given with the SDK… If you’ven’t heard of that… it must be linked to the security of the bank I’m working for… they don’t install software with the cds but download pre-installed package from a server…
Thanks for all dwayne and for having spent your time with my questions :wink: (well perhaps it’s not very english but I hope you ll understand)


Toby :fr: (BOB member since 2005-10-28)