Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Bulk-Delete All Custom Commandbars

Hi there,

Soppose I have bunch of files wich have quite a few different custom
commandbars (some are generated by code and some manually attached to the
file). The commandbar names may vary from file to file so it is difficult to
predict them. Is there a way to bulk-delete all CUSTOM commandbars without
having to specify their names?

Something like this:
For each cb in Application.CommandBars.CustomBars
cb.Delete
next cb

Also, is it possible in VBA to tell wheather a custom bar is attached to a
file?

Thanks,
KL


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Bulk-Delete All Custom Commandbars

from the help example for the Builtin property of a commandbar:

foundFlag = False
deletedBars = 0
For Each bar In CommandBars
If (bar.BuiltIn = False) And (bar.Visible = False) Then
bar.Delete
foundFlag = True
deletedBars = deletedBars + 1
End If
Next
If Not foundFlag Then
MsgBox "No command bars have been deleted."
Else
MsgBox deletedBars & " custom command bar(s) deleted."
End If
I can't say about the ability to inventory attached bars. I am not familiar
with any thing that would support that.
--
Regards,
Tom Ogilvy

"KL" <lapink2000(at)hotmail.com wrote in message
...
Hi there,

Soppose I have bunch of files wich have quite a few different custom
commandbars (some are generated by code and some manually attached to the
file). The commandbar names may vary from file to file so it is difficult

to
predict them. Is there a way to bulk-delete all CUSTOM commandbars without
having to specify their names?

Something like this:
For each cb in Application.CommandBars.CustomBars
cb.Delete
next cb

Also, is it possible in VBA to tell wheather a custom bar is attached to a
file?

Thanks,
KL




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Bulk-Delete All Custom Commandbars

Under the commandbars property of the Workbook object, in help it states:

"There is no programmatic way to return the set of command bars attached to
a workbook."

--
Regards,
Tom Ogilvy

"KL" <lapink2000(at)hotmail.com wrote in message
...
Hi there,

Soppose I have bunch of files wich have quite a few different custom
commandbars (some are generated by code and some manually attached to the
file). The commandbar names may vary from file to file so it is difficult

to
predict them. Is there a way to bulk-delete all CUSTOM commandbars without
having to specify their names?

Something like this:
For each cb in Application.CommandBars.CustomBars
cb.Delete
next cb

Also, is it possible in VBA to tell wheather a custom bar is attached to a
file?

Thanks,
KL




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Bulk-Delete All Custom Commandbars

Theres a lovely property "builtin" - from the help page:

BuiltIn Property
See Also Applies To Example Specifics
True if the specified command bar or command bar control
is a built-in command bar or control of the container
application. False if it's a custom command bar or
control, or if it's a built-in control whose OnAction
property has been set. Read-only Boolean.

Example
This example deletes all custom command bars that aren't
visible.

foundFlag = False
deletedBars = 0
For Each bar In CommandBars
If (bar.BuiltIn = False) And (bar.Visible = False) Then
bar.Delete
foundFlag = True
deletedBars = deletedBars + 1
End If
Next
If Not foundFlag Then
MsgBox "No command bars have been deleted."
Else
MsgBox deletedBars & " custom command bar(s) deleted."
End If

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Bulk-Delete All Custom Commandbars

Tom and Ben,

Thanks to both of you - that does the trick.

KL

"Ben McBen" wrote in message
...
Theres a lovely property "builtin" - from the help page:

BuiltIn Property
See Also Applies To Example Specifics
True if the specified command bar or command bar control
is a built-in command bar or control of the container
application. False if it's a custom command bar or
control, or if it's a built-in control whose OnAction
property has been set. Read-only Boolean.

Example
This example deletes all custom command bars that aren't
visible.

foundFlag = False
deletedBars = 0
For Each bar In CommandBars
If (bar.BuiltIn = False) And (bar.Visible = False) Then
bar.Delete
foundFlag = True
deletedBars = deletedBars + 1
End If
Next
If Not foundFlag Then
MsgBox "No command bars have been deleted."
Else
MsgBox deletedBars & " custom command bar(s) deleted."
End If



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
Excel: Cell Naming Bulk Delete Grant Excel Worksheet Functions 1 June 19th 08 07:22 PM
Prob: Custom CommandBars and .xls Files Being Re-Opened James Cox[_2_] Excel Programming 0 October 19th 04 03:34 PM
Custom faces for custom menus/commandbars Stu Valentine Excel Programming 1 September 17th 04 04:28 AM
Question on custom commandbars Mark Reynolds Excel Programming 3 January 23rd 04 11:55 PM
Temporarily delete ALL CommandBars? Kevin Excel Programming 3 August 26th 03 05:55 PM


All times are GMT +1. The time now is 03:28 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"