vbscript to remove custom Outlook Toolbars

  • Thread starter Thread starter movalgirl
  • Start date Start date
M

movalgirl

Hi all,

due to some faulty programming my C++ COMAddIn does not delete the
custom toolbar it has created.

I am attempting to write a vbscript which will allow the administrator
to cleanup this toolbar without having to install a macro/ComAddin or
anything of the sort.

Is this possible in vbscript? Can someone point me in the direction of
the OOM objects which are available in vbscript as opposed to VBA?


A small snippet of how I think the removal of the toolbar should work
is posted below.

--------------------------------------------------------------------------------

Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")
objNamespace.Logon "Outlook", , FALSE, TRUE

Set myOlExp = objOutlook.ActiveExplorer
Set myCmdBars = myOlExp.CommandBars

mycbars.delete("My toolbar")

Wscript.Echo "done"
objOutlook.Quit
 
Something like that should work, although I'd change the NameSpace.Logon to
objNameSpace.Logon "", "", False, True or even use False for the NewSession
argument.

Of course the real solution is to create the toolbar using the Temporary =
true argument and to explicitly delete it in the Explorer.Close() event
handler.
 
Thanks for the tip. Unfortunately, it is legacy code which creates
this permanent toolbar - new versions
only create the toolbar as a "temporary" toolbar. I have to work out
some way to automatically delete this permanent toolbar
during an upgrade of our software.


I am now using the following vbscript to delete the permanent toolbar.
The toolbar is deleted in the
current outlook session but at the next Outlook startup - there it is
again. Worse than the plague :-)

-----------------------------------------------------------------
Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")
objNamespace.Logon "","", FALSE, TRUE


Set oCBars = objOutlook.ActiveExplorer.CommandBars
For i = oCBars.Count To 1 Step -1
Wscript.Echo oCBars.Item(i).Name
If oCBars.Item(i).Name = "IXOSOST" Then
oCBars.Item(i).Delete
End If
Next


Wscript.Echo "done"
objOutlook.Quit
------------------------------------------------------------------------
p.s. i cannot simply delete the extend.dat file as the customer has
numerous
other addIns and not much of a sense of humour...

Thanks in advance,
movalgirl
 
Extend.dat has nothing to do with addins or toolbars, it's where ECE's are
set (Exchange extensions written in C++ or Delphi using Extended MAPI).

The toolbar/menu customizations are held in a file outcmd.dat, which is also
reconstructed when Outlook starts if it's not there.

However, given that code as soon as that addin runs again the toolbar will
be back and deleting it with an outside script or by deleting outcmd.dat are
your main options. Of course depending on how the addin is written, if it
doesn't check for at least one Explorer when Outlook starts then your script
will start Outlook and the addin and the toolbar will be created then again.




Thanks for the tip. Unfortunately, it is legacy code which creates
this permanent toolbar - new versions
only create the toolbar as a "temporary" toolbar. I have to work out
some way to automatically delete this permanent toolbar
during an upgrade of our software.


I am now using the following vbscript to delete the permanent toolbar.
The toolbar is deleted in the
current outlook session but at the next Outlook startup - there it is
again. Worse than the plague :-)

-----------------------------------------------------------------
Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")
objNamespace.Logon "","", FALSE, TRUE


Set oCBars = objOutlook.ActiveExplorer.CommandBars
For i = oCBars.Count To 1 Step -1
Wscript.Echo oCBars.Item(i).Name
If oCBars.Item(i).Name = "IXOSOST" Then
oCBars.Item(i).Delete
End If
Next


Wscript.Echo "done"
objOutlook.Quit
------------------------------------------------------------------------
p.s. i cannot simply delete the extend.dat file as the customer has
numerous
other addIns and not much of a sense of humour...

Thanks in advance,
movalgirl
 
Back
Top