Results 1 to 5 of 5

Thread: CommandBar Delete doesn't work

  1. #1

    Thread Starter
    Member
    Join Date
    May 2003
    Posts
    58

    CommandBar Delete doesn't work

    Hi seniors,

    I am developing an Add-In application for VS .NET. I have managed to create a toolbar (or commandbar). However, I could not delete it. It throws an exception when it reaches cmdbar.Delete() line. The error message is "Unspecified error".

    Try
    cmdbar = Me.applicationObject.CommandBars("MyAddIn")
    cmdbar.Delete()
    Catch ex As Exception

    End Try

    So far, I have found out that the cmdBar.BuiltIn property is True (as Standard toolbar has). This could be the reason why I could not delete this toolbar. But, how could it become True because it is not created by system default.

    Anyone have a clue?

  2. #2

    Thread Starter
    Member
    Join Date
    May 2003
    Posts
    58

    Resolved

    hahaha, i didn't notice remove commandbar function under commands.

  3. #3
    Addicted Member
    Join Date
    Jul 2003
    Posts
    232

    Question

    I am having a similar problem my commandbar is not getting removed, what is it you realized to add?

  4. #4

    Thread Starter
    Member
    Join Date
    May 2003
    Posts
    58
    There is a function to remove command bar called RemoveCommandBar in EnvDTE.DTE.Commands.RemoveCommandbar


    VB Code:
    1. mCmdBar = Me.applicationObject.CommandBars("CodingExt")
    2.  
    3.             'the cmdbar need to be set to invisible to prevent OnConnection_AfterStartup being invoked after OnDisconnection
    4.             mCmdBar.Visible = False
    5.  
    6.             Try
    7.                 Me.applicationObject.Commands.RemoveCommandBar(mCmdBar)
    8.             Catch ex As Exception
    9.                 MsgBox("Failed to remove CodingExt toolbar. " & ex.Message, MsgBoxStyle.Critical, "CodingExt")
    10.             End Try

    However, this portion of code can only remove the command bar while the add-ins is still actively running in .NET IDE. There is another problem that somehow the command bar is still attached even I have already uninstall it through Control Panel. This code might need to be placed in OnDisconnection procedure where

    ext_DisconnectMode = ext_dm_UISetupComplete

    not really sure????

  5. #5
    Addicted Member
    Join Date
    Jul 2003
    Posts
    232

    command bar buttons not executing correctly

    thanks for your response. I am using the regular commandbar.delete and it seems to be working but not all the time. let me back track a little. I am writing an outlook addin, where i add a commandbar every time the user double clicks on an email. I do it in the New_Inspector function. I then delete the commandbar in the Inspector_close function.
    I am having 2 problems with this maybe you can help me with one or both.

    the one i am more concerned with is that the tool bar has 2 buttons on it when i click on one of them it goes to the click of the other one and i cant figure out why. here is the code where i create the button:

    Set myCommandbar = objApp.ActiveExplorer.CommandBars.Add("AddinBar")
    Dim cb As CommandBar
    Set cb = myCommandbar

    Set oEvt = New CBTnEvent
    Set oStw = New CBSaveToweb
    Set oEvt.oBtn = cb.Controls.Add(msoControlButton)
    With oEvt.oBtn
    If NewInspector Then
    .Tag = "Inspector"
    Else
    .Tag = "Explorer"
    End If
    .Style = msoButtonIconAndCaption
    .FaceId = 67
    .Caption = "Junk Mail"
    End With
    Set oStw.oBtn = cb.Controls.Add(msoControlButton)
    With oStw.oBtn
    If Not NewInspector Then
    .Tag = "Inspector"
    Else
    .Tag = "Explorer"
    End If
    .Style = msoButtonIconAndCaption
    .FaceId = 271
    .Caption = "Save To Web"
    End With

    cb.Visible = True
    cb.Position = msoBarTop
    'cb.Protection = msoBarNoCustomize
    oBtns.Add oEvt
    oBtns.Add oStw

    Set cb = Nothing
    End Sub
    CBTnEvent and CBSaveToweb are 2 classes which have a click event of the button. when i click on the button for cbtnevent it seems to be going to the cbsavetoweb click event.

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