Is there a simple way to list all the toolbars a user currently has visible?


I'm trying to hide everything on screen appart from my worksheet, including the file menu. I've found a way to do it (custom toolbar, hide everything else) but need to be able to restore the original toolbar config when the user exits my app (cos people HATE it when you screw with their setup).

My app is going to run on multiple versions of excel (possibly every version of excel from 97 through to the latest) and I'm developing in excel XP (2003). I'm using the code:

if application.commandbars("toolbar name").visible = true then
   ' {log it to somewhere the user can't see}
     application.commandbars("toolbar name").visible = false
   ' {repeat for all the toolbars I know the names of}
end if

however......I only have one version of excel to play with so not only could a user be running a toolbar not native to excel XP (so I won't know the name of it) but also custom toolbars, which also need to be hidden.

So.....as I say, is there a way to list all toolbars visible?

You can try experimenting with this, it might need some playing with to get it working

Dim thiscombar As CommandBar
For Each thiscombar In Application.CommandBars
     thiscombar.Visible = False
Next thiscombar
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.