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 & "\ICO.BMP") <> "" Then
Application.Clipboard.SetData LoadPicture(ThisDocument.Path & "\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?
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:
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?
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 except the icon is really ugly… even in 16 colors…
Well, I can’t help with “ugly” icons I’m afraid . 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.
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
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 (well perhaps it’s not very english but I hope you ll understand)