View Single Post
  #3  
Old August 22nd 08, 07:55 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Command Bar Button not working --Inspector Wrapper

At module level in the Inspector wrapper:

Dim blnMenuExists As Boolean

In Activate():

If Not blnMenuExists Then
InitButton

blnMenuExists = True
End If

That calls InitButton only once, which then calls CreateMenu. You needed no
changes to CreateMenu.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"amanat via OfficeKB.com" u45636@uwe wrote in message
news:890de7c6ecfad@uwe...
Hey Ken ,
Thanks for quick reply, Can you please guide me in detail as to what
should
I do once again , I did folling changes in create menu :

Private Sub createmenu()
Dim oControl As office.CommandBarControl
Dim m_ocontrolbar As CommandBarControl
Dim strMenu As String
Dim strTag As String
Dim strToolTip As String
Dim strCaption As String
Dim strKey As String
Dim blnMenuExists As Boolean
Dim oCommandBar As office.CommandBar
Dim oStandardBar As office.CommandBar

On Error Resume Next

strKey = CStr(m_intID)
mnuTag = "This string is unique to this menu" & strKey

strMenu = "Menu Bar"

strToolTip = "The ToolTip for the menu"
strCaption = "The caption for the menu"

'check for the menu existing already and do not create
' it if does exist. The checking code would set a
' Boolean variable named blnMenuExists.

If Not blnMenuExists Then
Set oControl = m_obj.CommandBars.FindControl(Tag:=btnTag)
Else
Set oControl = m_obj.CommandBars.FindControl(Tag:=btnTag)
End If

'now add a button to the new menu that was created
If Not (oControl Is Nothing) Then
Set m_ocontrolbar = oControl

strTag = "This string is unique to this button" & strKey
strToolTip = "The ToolTip for the button"
strCaption = "testing123"

'create the button here
Set ctlbtnpriv = oStandardBar.Controls.Add(Type:=msoControlButton,
Temporary:=True)
With ctlbtnpriv
Caption = strCaption
Tag = btnTag
ToolTipText = strToolTip
Style = msoButtonCaption
Visible = True
End With
End If
' End If

Set oControl = Nothing

End Sub
'--------------------------------------------------------------------------
Private Sub m_objInsp_Activate()
On Error Resume Next
Call CreateButton(m_objInsp)
End Sub

Please , I really need your help.Thanks


Ads