Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default delete toolbar

I have a button which creates, enables, and makes visible a toolbar. How do
I delete the toolbar when the user is done with it? I can make a toolbar
button that deletes the toolbar, but how do I do this if the user uses the
view menu or clicks the X in the corner of the toolbar to make it not
visible? So, if the toolbar exists, I would like it to be visible, if it is
not visible or made not visible, I don't want it to continue to exist. Any
ideas?

Thanks
Dave
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default delete toolbar

Sorry, seem to have figured it out:

set cmdbar = application.commandbars.add("MyBar")
with cmdbar
.protection = msoBarNoChangeVisible + msoBarNoCustomize
End with

Thanks again
Dave


"drhalter" wrote:

I have a button which creates, enables, and makes visible a toolbar. How do
I delete the toolbar when the user is done with it? I can make a toolbar
button that deletes the toolbar, but how do I do this if the user uses the
view menu or clicks the X in the corner of the toolbar to make it not
visible? So, if the toolbar exists, I would like it to be visible, if it is
not visible or made not visible, I don't want it to continue to exist. Any
ideas?

Thanks
Dave

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 535
Default delete toolbar

Hi Drhalter,

So, if the toolbar exists, I would like it to be visible, if it is
not visible or made not visible, I don't want it to continue to exist. Any
ideas?



This gives you an idea how to create a bar that cannot be closed:

Sub createbar()
Dim oBar As CommandBar
removebar
Set oBar = CommandBars.Add
oBar.Name = "Test"
oBar.Protection = msoBarNoChangeVisible
oBar.Visible = True
End Sub

Sub removebar()
On Error Resume Next
Application.CommandBars("Test").Delete
End Sub

Regards,

Jan Karel Pieterse
Excel MVP
http://www.jkp-ads.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default delete toolbar

That's great. I posted just prior to yours, I happened to think of how to do
it about 2 seconds after I posted the original question. But, any ideas on
how to test whether the toolbar exists? I have the following code in a
workbook_sheetcalculate event:

If application.commandbars("myBar").visible = true then

but I get an error when myBar doesn't exist. The code works great when the
toolbar does exist.

Thanks
Dave

"Jan Karel Pieterse" wrote:

Hi Drhalter,

So, if the toolbar exists, I would like it to be visible, if it is
not visible or made not visible, I don't want it to continue to exist. Any
ideas?



This gives you an idea how to create a bar that cannot be closed:

Sub createbar()
Dim oBar As CommandBar
removebar
Set oBar = CommandBars.Add
oBar.Name = "Test"
oBar.Protection = msoBarNoChangeVisible
oBar.Visible = True
End Sub

Sub removebar()
On Error Resume Next
Application.CommandBars("Test").Delete
End Sub

Regards,

Jan Karel Pieterse
Excel MVP
http://www.jkp-ads.com


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 535
Default delete toolbar

Hi Drhalter,

That's great. I posted just prior to yours, I happened to think of how to do
it about 2 seconds after I posted the original question. But, any ideas on
how to test whether the toolbar exists? I have the following code in a
workbook_sheetcalculate event:

If application.commandbars("myBar").visible = true then

but I get an error when myBar doesn't exist. The code works great when the
toolbar does exist.


Dim oBar as CommandBar
On Error Resume next
Set oBar=Application.Commandbars("YourBar")
If oBar is nothing then
'Bar is absent
Else
'Do your thing
End If

Regards,

Jan Karel Pieterse
Excel MVP
http://www.jkp-ads.com



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default delete toolbar

Thanks, that does it.

"Jan Karel Pieterse" wrote:

Hi Drhalter,

That's great. I posted just prior to yours, I happened to think of how to do
it about 2 seconds after I posted the original question. But, any ideas on
how to test whether the toolbar exists? I have the following code in a
workbook_sheetcalculate event:

If application.commandbars("myBar").visible = true then

but I get an error when myBar doesn't exist. The code works great when the
toolbar does exist.


Dim oBar as CommandBar
On Error Resume next
Set oBar=Application.Commandbars("YourBar")
If oBar is nothing then
'Bar is absent
Else
'Do your thing
End If

Regards,

Jan Karel Pieterse
Excel MVP
http://www.jkp-ads.com


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
Help!! I am trying to delete a toolbar (avery) bvealey Excel Discussion (Misc queries) 16 February 4th 16 03:58 PM
permanently delete toolbar rrChuck Excel Discussion (Misc queries) 2 October 28th 09 01:44 PM
delete control toolbar check box paul[_2_] Excel Discussion (Misc queries) 3 May 15th 07 11:37 AM
How to Delete a persistent Toolbar? alainr Excel Discussion (Misc queries) 6 October 6th 05 04:29 PM
delete custom toolbar billQ Excel Programming 1 July 30th 03 03:50 PM


All times are GMT +1. The time now is 11:49 AM.

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

About Us

"It's about Microsoft Excel"