Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Create/Remove toolbars

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Create/Remove toolbars

That might be one way, but would be hard to maintain. If the workbooks
that require the macro have some unique attribute you can look for, then
have your auto_close code search the open workbooks to see if there are any
others open that require the menu.

--
Regards,
Tom Ogilvy

"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




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Create/Remove toolbars


I've added code to the auto_close to count "Form Options" worksheets; one of
the sheets that I have in my app. If I find more than one sheet with this
name, then I leave the toolbar alone. If there is only one, I dispose of the
toolbar.

Seems to be working Ok at the moment.

I may go back to the workbook_activate events later. I had tried them, but
they didn't seem to fire when I closed a workbook. For example, if I had two
books open (A & B) then closing A didn't fire the activate event in B. It
might have been my code, but I don't think so.

Many thanks
Steve


"Tom Ogilvy" wrote in message
...
That might be one way, but would be hard to maintain. If the workbooks
that require the macro have some unique attribute you can look for, then
have your auto_close code search the open workbooks to see if there are

any
others open that require the menu.

--
Regards,
Tom Ogilvy

"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






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Create/Remove toolbars

Hi Steve

Maybe this is a option for you
You can use the Activate event and the deactivate event to create and delete your toolbars

Private Sub Workbook_Activate()

End Sub

Private Sub Workbook_Deactivate()

End Sub

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"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




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Create/Remove toolbars

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






  #6   Report Post  
Posted to microsoft.public.excel.programming
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






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I create a formula to remove dashes? jackierae17 Excel Discussion (Misc queries) 5 May 5th 10 03:04 PM
Remove Toolbars and Menus but keep print button L Weber Excel Discussion (Misc queries) 3 October 18th 07 09:51 PM
Remove Formula Bar / Toolbars etc cassy01 Excel Discussion (Misc queries) 2 January 19th 06 12:04 PM
Remove toolbars George Setting up and Configuration of Excel 0 February 5th 05 02:22 PM
How do I remove toolbars and specific menus items to restrict use? Brian Excel Programming 0 October 26th 03 10:14 PM


All times are GMT +1. The time now is 12:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"