View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Rob Bovey Rob Bovey is offline
external usenet poster
 
Posts: 811
Default How to distribute custom toolbar updates?

Hi Larry,

I know this really doesn't answer your question, but I've found attached
toolbars to be a real nuisance. I think it's much cleaner to build your
toolbar dynamically each time your app is opened and delete it when your app
is closed.

You should always build logic into your Auto_Open (or Workbook_Open)
procedure to delete any previously existing toolbars of the same name prior
to building the toolbar for your application, in case a previous version was
left behind by a crash or some other incomplete exit of your program, and
this will also take care of any left over attached toolbars.

So a skeleton of the logic would look something like this:

Sub Auto_Open()
Dim cbrBar As CommandBar
Dim ctlControl As CommandBarControl
On Error Resume Next
''' Remove any pre-existing version of the toolbar.
CommandBars("MyToolbar").Delete
On Error GoTo 0
''' Build the new toolbar.
Set cbrBar = CommandBars.Add("MyToolbar", False)
Set ctlControl = cbrBar.Controls.Add(msoControlButton)
'''....etc....
End Sub

Sub Auto_Close()
On Error Resume Next
''' Remove the toolbar on exit.
CommandBars("MyToolbar").Delete
On Error GoTo 0
End Sub

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"Larry Adams" wrote in message
...
Has anyone run across a clean and automated way to distribute an Excel
workbook application containing an updated attached toolbar -- such that
it will replace any previous toolbar of the same name in a user's Excel
workspace on their PC? Everything I've seen so far suggests that one
must first delete any same named toolbar in the local Excel workspace
BEFORE the custom Excel application is loaded-- at which point any
attached custom toolbar will again be copied to the local PC. Which is
fine, and works, but is not very elegant for distribution purposes.

Any thoughts??? Much appreciated!! Larry.