You are here: Office-Outlook.com  / Outlook Forum

Re: Two CommandBarButtons that run the same event code

Home » Outlook addins and plugins development » Developer Outlook add-ins
Re: Two CommandBarButtons that run the same event code [message #591] Sun, 09 July 2006 01:19
DavidE
Messages: 122
Registered: July 2006
Senior Member
Thanks Ken.
The problem was with the Tag property that was the same in both commands.
Sorry for the late response.I wasn't here.

David

"Ken Slovak - [MVP - Outlook]" wrote:

> Both projects should have unique ProgID's and you need to make sure that
> both buttons have unique Tag properties. I would check and make sure that's
> the case. If the Inspector is the first one it looks to me like both would
> have a Tag of 1. You would need a unique string to add to that.
>
> Addin 1:
>
> strTag = "Addin1" & CStr(m_intID)
>
> Addin 2:
> strTag = "Addin2" & CStr(m_intID)
>
>
> --
> Ken Slovak
> [MVP - Outlook]
> http://www.slovaktech.com
> Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
> Reminder Manager, Extended Reminders, Attachment Options
> http://www.slovaktech.com/products.htm
>
>
> "DavidE" <DavidE@discussions.microsoft.com> wrote in message
> news:B8E95F80-DF26-4194-A9BD-9225030389DE@microsoft.com...
> > Hi ,
> > I create two CommandBarButtons in two seperate projects.I add This buttons
> > to the standard Command bar. When I click one of them the event runs the
> > code
> > of the both AddIns. To solve this problem I add the 'OnAction' property on
> > the creation of the buttons, but it doesn't help, each button runs the
> > code
> > of the both AddIns .
> > Here the code :
> > 'The first button :
> > Private Sub CreateButtons(objInspector As Outlook.Inspector)
> > On Error Resume Next
> >
> > 'Adding a new menu item and a button to the main menu for any Inspector
> > ' must take a different approach if using Word as email editor.
> >
> > Dim objCB As Office.CommandBar
> > Dim strKey As String
> >
> > Set objCB = m_objInsp.CommandBars("standard")
> >
> > strKey = CStr(m_intID)
> > strTag = "This string is unique to this button" & strKey
> > Set cbbFaxButton = objCB.Controls.Add(Type:=msoControlButton,
> > Temporary:=True)
> >
> > With cbbFaxButton
> > .ToolTipText = "Send fax"
> > .Tag = strTag
> > .Style = msoButtonIconAndCaption
> > .FaceId = 461
> > .Caption = "fax"
> > .Visible = True
> > .OnAction = "<!" & strProgId & ">"
> > End With
> >
> > Set objCB = Nothing
> > Err.Clear
> >
> > End Sub
> > **************
> > The .OnAction property get this value :
> > <!FaxSystem.fax_Connect>
> >
> >
> > '*** The second button
> >
> > Private Sub CreateButtons(objInspector As Outlook.Inspector)
> > On Error Resume Next
> >
> > Dim oPic As StdPicture
> > Dim objCB As Office.CommandBar
> > Dim strKey As String
> >
> > Set objCB = objInspector.CommandBars("standard")
> >
> > strKey = CStr(m_intID)
> > strTag = "This string is unique to this button" & strKey
> > Set cbbButton = objCB.Controls.Add(Type:=msoControlButton,
> > Temporary:=True)
> >
> > With cbbButton
> > .ToolTipText = "Send to Mrkv"
> > .Tag = strTag
> > .Style = msoButtonIconAndCaption
> > .Caption = "Mrkv"
> > .Visible = True
> > .OnAction = "<!" & strProgId & ">"
> >
> > End With
> >
> > Set objCB = Nothing
> > Set objOutAddIn = Nothing
> > Err.Clear
> >
> > End Sub
> >
> > **********
> > The .OnAction property get this value :
> > <!Merkava.Mrkv_Connect>
> >
> > How can I solve this problem ?
> >
> > Thanks,
> > David
>
>
Previous Topic:Outlook Custom form - resize event handling
Next Topic:Accessing addin startuppath
Goto Forum: