View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Steve Barnett Steve Barnett is offline
external usenet poster
 
Posts: 18
Default Create/Remove toolbars

I can't predict how many workbooks the user will open, or their names. What
I've done is scan Excel for all worksheet names and count those with a
specific name that matches my application. It's not brilliant, but seems to
be working.

Thanks
Steve


"Bob Phillips" wrote in message
...
Why not just check if the other workbook is also open. Something like

Dim oWb As Workbook

On Error Resume Next
If ThisWorkbook.Name = "Workbook A" Then
Set oWb = Workbooks("Workbook B")
Else
Set oWb = Workbooks("Workbook A")
End If
On Error GoTo 0

If oWb Is Nothing Then
DeleteToolbar
End If


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Steve Barnett" wrote in message
...
I have an application that adds a toolbar as part of it's auto_open
processing. During auto_close, it removes the toolbar.

The problem comes if I open two spreadsheets with this code in. The

second
one detects that the toolbar is already there, so does not try to load

it
a
second time. However, if I close one of the sheets, the auto_close fires

and
the toolbar is taken away. This leaves the first sheet sitting there

without
it's tool bar.

Is there any way of maintaining a reference count such that I only

delete
the toolbar when it's no longer needed?

Thanks
Steve