Remove OutlookBarShortcut

  • Thread starter Thread starter dorutzu
  • Start date Start date
D

dorutzu

Hi,

I'm trying to programatically remove a shortcut to a folder from the
OutlookBar. The problem is that I get a "Run-time error 13: Type
mismatch" message when I try to run my code.

Sub test5()
Dim myOlBar As OutlookBarPane
Set myOlBar = Application.ActiveExplorer.Panes.Item("OutlookBar")
myOlBar.Contents.Groups.Item(1).Shortcuts.Remove ("ShortcutName")
End Sub

Also, I know for a fact that this shortcut exist - here is the code
again, modified a bit:

Sub test5()
Dim myOlBar As OutlookBarPane
Set myOlBar = Application.ActiveExplorer.Panes.Item("OutlookBar")
Set mySh = myOlBar.Contents.Groups.Item(1).Shortcuts.Item("ShortcutName")
'see if I got what I needed...
MsgBox mySh.Name 'indeed, "ShortcutName" appears in the messagebox
'now try to remove the shortcut with this EXACT name
myOlBar.Contents.Groups.Item(1).Shortcuts.Remove (mySh.Name) 'I get
the type mismatch error here :((
End Sub

The idea is that Remove does not work with the name of the shortcut
(apparently), only with it's index. Any idea how can I get the index
of my shortcut instead (except for iterating trough Shortcuts)?

Thanks,
Doru
 
Loop through the Shortcuts collection checking the name of each item, then remove the one that matches:

Set scuts = myOlBar.Contents.Groups.Item(1).Shortcuts
For i = 1 to scuts.Count
If scuts(i).Name = "ShortcutName"
scuts.Remove i
Exit For
End If
Next
 
Back
Top