ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel 2003 VBA: Detecting and removing toolbars (https://www.excelbanter.com/excel-programming/344873-excel-2003-vba-detecting-removing-toolbars.html)

Henry[_8_]

Excel 2003 VBA: Detecting and removing toolbars
 
I'm working on a project in which I need to detect which toolbars the
user has in Excel 2003 when they launch Excel, delete all of them,
choose and run a spreadsheet (in a new instance of Excel) and restore
all of the toolbars as they were when the user started the app.

I've had some relatively limited success by iterating through the
Application.Toolbars collection, but there seems to be a bit of an
inconsistency. I have set up a module with all of the global
declarations I believe I'll need. Via some VBA code I found, I believe,
at J-Walk.com, that showed how to get a listing of all toolbar names.
I've found that it's not enough to sense only if a toolbar is enabled-
you also have to consider the toolbar's TYPE. And even here there seems
to be some inconsistency. FOr some toolbars, such as Visual Basic, you
need to see if

Application.CommandBars("Visual Basic").Enabled = True AND _
Application.CommandBars("Visual Basic").Type = msoBarTypeNormal

However, for a toolbar such as, let's say, Formatting, you need to say:

Application.CommandBars("Formatting").Enabled = True AND _
Application.CommandBars("Formatting").Type = 0


I'm sure that I'm missing something, but this doesn't seem to be at all
intuitive. I don't think that I should have to consider a constant in
some cases and a value in others. Am I missing something here? IS
there a better way to do this? I'd appreciate any assistance.


Henry
DPM Mellon


All times are GMT +1. The time now is 05:35 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com