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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hide Toolbar via macro in Word?

Status
Not open for further replies.

cheriberi

Technical User
May 27, 2003
60
US
Is there a way to hide a toolbar when Word is opened? I have a template in my Startup folder (Windows NT) which contains 3 toolbars. I only want to see one of those toolbars when Word is first opened. Is there a way to make sure the other 2 toolbars don't automatically appear? It seems like whichever of the 2 is on screen when I close Word will be on screen when I open it, even though I have the following code in the template:

Code:
Private Sub Document_New()

' Ensure Misc toolbar is always enabled
CommandBars("Miscellaneous").Visible = True
' Always hide Styles toolbars
CommandBars("Styles1").Visible = False
CommandBars("Styles2").Visible = False

End Sub

Private Sub Document_Open()

' Ensure Misc toolbar is always enabled
CommandBars("Miscellaneous").Visible = True
' Always hide Styles toolbars
CommandBars("Styles1").Visible = False
CommandBars("Styles2").Visible = False

End Sub

Thanks for any help you can give!
 
cheriberi;

While I think I understand what you wnat, I am wondering if I am even in the right ballpark...

Perhaps if you attached that macro into the normal.dot, this would help. That template is the one that rules default behaviors when you start word. It will also maintain whatever behavior you specify when creating a new document.

Good luck!


~wmichael

"small change can often be found under seat cushions
 
Unfortunately, we are not allowed to edit the Normal template. The template that contains the toolbars is also in the Startup folder. So I thought there should be a way to hide the toolbars in the template itself since (like the Normal template) it is always there.
 
If it is in Startup it should show as checked in global templates loaded list. Check and make sure.

Put your routine as Sub AutoExec(), not as Document_Open. This can be either in ThisDocument of the template, or in a module.

When you load (as Startup) a global template, the macros are available, but even AutoNew, or AutoOpen do not run from a global template. They DO run if you use File/New to CALL a template. Document_Open does not run from a global template either - simply because that template did not create or open a document, normal.dot did. However, using AutoExec will run code in a global template. This includes changing Commandbars.

Hope this helps.




Gerry
 
Okay, I checked and my template is listed in the global templates loaded list. So I deleted the code I had in Document_Open and Document_New and replaced with the following:

Code:
Private Sub AutoExec()

' Ensure Enabler Misc toolbar is always enabled
CommandBars("Enabler Miscellaneous").Visible = True
' Always hide Styles toolbars
CommandBars("EN1--Enabler Styles").Visible = False
CommandBars("EN2--Enabler Styles").Visible = False

End Sub

I tried it in both the "This Document" module and then in a new module, but it didn't work in either location. I'm in Windows NT--would that make a difference? I also tried it using "Visible" and using "Enabled".

No matter what I tried, whichever toolbar was open the last time I was in Word is there when I open Word the next time. I can't get them to both not display.

Cheryl

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top