Results 1 to 4 of 4

Thread: strange occurance, why does this happen??

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2006
    Posts
    80

    strange occurance, why does this happen??

    ho there

    i have a control whihc is added to the menu bar in outlook, but when i change to a non mail folder , the control is dupplicated.

    its very strange bexcause the routine which creates control in the first place isnt fired (on_connection) .

    why does this happen

    many thanks

    jamie

  2. #2
    Frenzied Member DKenny's Avatar
    Join Date
    Sep 2005
    Location
    on the good ship oblivion..
    Posts
    1,171

    Re: strange occurance, why does this happen??

    Jamie
    In the procedure you use to create/add the control, your first step should be to call the procedure you use to remove the control. That way you will never get duplication.
    Declan

    Don't forget to mark your Thread as resolved.
    Take a moment to rate posts that you think are helpful

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 2006
    Posts
    80

    Re: strange occurance, why does this happen??

    i have tried this but i still get the control duplicated

    this is very wierd. here is my code whihc ceates the control.

    VB Code:
    1. Dim WithEvents oApp As Outlook.Application
    2.  
    3.  
    4. Private Sub addMenuBarControls()
    5.     ' This subroutine is called when Add-in is connected
    6.     ' to by the host application.
    7.  
    8.     ' Get the Application object for Outlook.
    9.     Dim objApp As Outlook.Application
    10.     Set objApp = Outlook.Application
    11.        
    12.        
    13.         Dim testcontrol As Office.CommandBarControl
    14.    
    15.         On Error Resume Next
    16.         Set testcontrol = objApp.ActiveExplorer.CommandBars.item("Menu bar").controls.item("&Iscent Evidence")
    17.    
    18.         If testcontrol Is Nothing Then
    19.         Else
    20.             testcontrol.Delete
    21.         End If
    22.        
    23.         Set omycontrol = objApp.ActiveExplorer.CommandBars.item("Menu Bar").controls.Add(Type:=msoControlPopup, Temporary:=True)
    24.         omycontrol.Caption = "&Iscent Evidence"
    25.        
    26.         Set oAboutMenuBar = omycontrol.controls.Add(Type:=msoControlButton, Temporary:=True, Before:=1)
    27.         oAboutMenuBar.Caption = "&About"
    28.         oAboutMenuBar.Enabled = True
    29.        
    30.         Set oHelpMenuBar = omycontrol.controls.Add(Type:=msoControlButton, Temporary:=True, Before:=1)
    31.         oHelpMenuBar.Caption = "&Help"
    32.         oHelpMenuBar.Enabled = True
    33.        
    34.         Set oExtractMenuBar = omycontrol.controls.Add(Type:=msoControlButton, Temporary:=True, Before:=1)
    35.         oExtractMenuBar.Caption = "&Extract"
    36.         oExtractMenuBar.Enabled = True
    37.        
    38.         Set oVerifyMenuBar = omycontrol.controls.Add(Type:=msoControlButton, Temporary:=True, Before:=1)
    39.         oVerifyMenuBar.Caption = "&Verify Document"
    40.         oVerifyMenuBar.Enabled = True
    41.        
    42.         Set oSealandSendMenuBar = omycontrol.controls.Add(Type:=msoControlButton, Temporary:=True, Before:=1)
    43.         oSealandSendMenuBar.Caption = "&Seal and Send"
    44.         oSealandSendMenuBar.Enabled = True
    45.  
    46.    
    47.     Set objApp = Nothing
    48.     Set testcontrol = Nothing
    49.    
    50. End Sub

    is this code correct?

    i create a local application object within the routinem, is this ok, or should i use the application declared with events?

    does this make any difference

    cheers

    jamie

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jan 2006
    Posts
    80

    Re: strange occurance, why does this happen??

    hi there

    heres the code my class. it has been stripped down of everything else, yet the control still gets duplicated on folder swotch

    does anyone know why?




    Code:
    Implements IDTExtensibility2
    
    
    
    Private Sub IDTExtensibility2_OnAddInsUpdate( _
            custom() As Variant)
    
        ' Use this subroutine when Add-ins are updated.
        'MsgBox "OnAddInsUpdate called"
        
    End Sub
    
    ' Use this subroutine when the host app is shutting down.
    ' You should persist or destroy your objects in this
    ' subroutine.
    Private Sub IDTExtensibility2_OnBeginShutdown( _
        custom() As Variant)
    
    End Sub
    
    
    
    Private Sub IDTExtensibility2_OnDisconnection( _
        ByVal RemoveMode As _
            AddInDesignerObjects.ext_DisconnectMode, _
        custom() As Variant)
    
        ' This Sub is called when your add-in is
        ' disconnected from the host.
        MsgBox "OnDisconnection called"
    End Sub
    
    
    
    Private Sub IDTExtensibility2_OnStartupComplete( _
        custom() As Variant)
    
        ' This Sub is called when the host application has
        ' completed its startup routines.
        'MsgBox "OnStartupComplete called"
    End Sub
    
    
    
    Private Sub IDTExtensibility2_OnConnection( _
        ByVal Application As Object, ByVal ConnectMode As _
        AddInDesignerObjects.ext_ConnectMode, _
        ByVal AddInInst As Object, custom() As Variant)
        
        addMenuBarControls
        
    End Sub
    
    
    '==========================================================================================
    'BUILD CONTROLS METHODS
    
    Private Sub addMenuBarControls()
        ' This subroutine is called when Add-in is connected
        ' to by the host application.
    
        ' Get the Application object for Outlook.
        Dim objApp As Outlook.Application
        Set objApp = Outlook.Application
            MsgBox "Menu being added"
            
            Dim testcontrol As Office.CommandBarControl
        
            On Error Resume Next
            Set testcontrol = objApp.ActiveExplorer.CommandBars.Item("Menu bar").Controls.Item("&New Control")
        
            If testcontrol Is Nothing Then
            Else
                testcontrol.Delete
            End If
            
            Dim lPosition As Long
            Dim ctlControl As CommandBarControl
    
        
                'Determine the Position of the Help MENU
            For Each ctlControl In objApp.ActiveExplorer.CommandBars.Item("Menu Bar").Controls
                If ctlControl.Caption = "&Help" Then
                    lPosition = ctlControl.Index
                    Exit For
                End If
            Next
            
            Set omycontrol = objApp.ActiveExplorer.CommandBars.Item("Menu Bar").Controls.Add(msoControlPopup, , , lPosition, True)
            omycontrol.Caption = "&Test"
            
            Set oAboutMenuBar = omycontrol.Controls.Add(msoControlButton, , , , True)
            oAboutMenuBar.Caption = "&About"
            oAboutMenuBar.Enabled = True
            
            Set oHelpMenuBar = omycontrol.Controls.Add(msoControlButton, , , , True)
            oHelpMenuBar.Caption = "&Help"
            oHelpMenuBar.Enabled = True
            
            Set oExtractMenuBar = omycontrol.Controls.Add(msoControlButton, , , , True)
            oExtractMenuBar.Caption = "&Other"
            oExtractMenuBar.Enabled = True
            
            Set oVerifyMenuBar = omycontrol.Controls.Add(msoControlButton, , , , True)
            oVerifyMenuBar.Caption = "&Verify"
            oVerifyMenuBar.Enabled = True
            
            Set oSealandSendMenuBar = omycontrol.Controls.Add(msoControlButton, , , , True)
            oSealandSendMenuBar.Caption = "&Send"
            oSealandSendMenuBar.Enabled = True
    
        
        Set objApp = Nothing
        Set testcontrol = Nothing
        
    End Sub
    if someone could have a go on their pc, and then try switching folders, to see what happen. i have tested on teo and the control gets duplicated

    many thannks

    Jamie
    Last edited by jamielawjen; Jan 31st, 2006 at 04:53 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width