R
Roy H. Berger
I am seeing a rather odd problem when adding a custom toolbar from an
add-in. The add-in potentially adds three custom toolbars, but the
performance problem only seems to occur when the first toolbar is
added. And it only seems to be a problem when you add/delete
something from the Application.CommmandBars collection for the first
time. I am running Office 2003 on WinXP Pro.
For instance, I had the following code:
On Error Resume Next
Application.CommandBars("My Toolbar").Delete
On Error GoTo 0
Set TM1Toolbar = Application.CommandBars.Add("My Toolbar",
msoBarTop, False, True)
Set MyToolbar_Default = TM1Toolbar
....
On the above code, the "Delete" operation took 20-30 seconds. So
then, figuring that the delete of something that potentially wasn't
there (I clean up when the work book closes) was causing some sort of
problem, I bracketed the delete code as follows:
If (Not MyToolbar_Default Is Nothing) Then
Application.CommandBars("My Toolbar").Delete
End If
So I was no longer doing an extraneous delete. This just pushed the
problem to the "Add":
Set TM1Toolbar = Application.CommandBars.Add("My Toolbar",
msoBarTop, False, True)
This line now took 20-30 seconds to run. Now this is before I even
start adding buttons to the toolbar. In fact those button add
operations run quickly as well as adding the additional toolbars. It
just seems like the first "access" to the Application.CommmandBars
collection is causing some sort of delay. Anyone ever seen this
before?
TIA
Regards,
Roy Berger
[email protected]
add-in. The add-in potentially adds three custom toolbars, but the
performance problem only seems to occur when the first toolbar is
added. And it only seems to be a problem when you add/delete
something from the Application.CommmandBars collection for the first
time. I am running Office 2003 on WinXP Pro.
For instance, I had the following code:
On Error Resume Next
Application.CommandBars("My Toolbar").Delete
On Error GoTo 0
Set TM1Toolbar = Application.CommandBars.Add("My Toolbar",
msoBarTop, False, True)
Set MyToolbar_Default = TM1Toolbar
....
On the above code, the "Delete" operation took 20-30 seconds. So
then, figuring that the delete of something that potentially wasn't
there (I clean up when the work book closes) was causing some sort of
problem, I bracketed the delete code as follows:
If (Not MyToolbar_Default Is Nothing) Then
Application.CommandBars("My Toolbar").Delete
End If
So I was no longer doing an extraneous delete. This just pushed the
problem to the "Add":
Set TM1Toolbar = Application.CommandBars.Add("My Toolbar",
msoBarTop, False, True)
This line now took 20-30 seconds to run. Now this is before I even
start adding buttons to the toolbar. In fact those button add
operations run quickly as well as adding the additional toolbars. It
just seems like the first "access" to the Application.CommmandBars
collection is causing some sort of delay. Anyone ever seen this
before?
TIA
Regards,
Roy Berger
[email protected]