Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Easier way to delete Tbars and Cbars please????

Status
Not open for further replies.

ribhead

Technical User
Jun 2, 2003
384
US
I am just trying to learn how to do some of this variable assigning and loops but I don't have a good grip on it yet. Any help/suggestions would be great!!!!

Sub cbars_delete()
holycow
End Sub
Function holycow()
Dim cbar As CommandBar
cb = cbar.BuiltIn
For Each cb In CommandBars
cbar.Delete
Next cb
End Function

I may not be very smart but I'm sure wirey!!!!
 
Hi
I'm not entirely sure what you're looking to learn here but this is an adaption of your code that might give some help.

Code:
Sub cbars_delete()
holycow
End Sub

Function holycow()
Dim cbar As CommandBar
For Each cbar In CommandBars
    If cbar.BuiltIn = False Then
        Debug.Print cbar.Name
    End If
Next cbar
End Function

This should print the names of the custom toolbars you have in Excel to the debug window. You might want to reconsider using the delete method while you're still learning!

Note there is no need for your second variable 'cb' which is probably the only point where your code would fall. Also have a look at the help on the BuiltIn property to see why "
Code:
cb = cbar.BuiltIn
" produces an error.

Good Luck
Happy Friday
;-)


If a man says something and there are no women there to hear him, is he still wrong? [ponder]
The faqs ma'am, just the faqs. Get the best from these forums : faq222-2244
 
Loomah, I know this was a Post from a while back but this is what I came up with and wanted.


Sub cya()
For Each cb In CommandBars
If cb.BuiltIn Then
With cb
.Enabled = False
End With
Else: End If
Next
End Sub

For just $19.95 you too can have a beautiful smile.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top