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?
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.