Solved

Disable a Word toolbar using VBA

Posted on 2004-04-13
1
677 Views
Last Modified: 2008-02-01
Using VBA, I need to disable the "Standard" toolbar for the currently active document, without affecting the normal.dot template
0
Comment
Question by:TeamWe
1 Comment
 
LVL 24

Accepted Solution

by:
R_Rajesh earned 125 total points
ID: 10815612
Hi TeamWe,

by accessing the applications commanbars collettion you can enable or disable particular command bars
Application.CommandBars("Standard").Enabled = False

save your document. press alt+f11, this opens the vbe window, on the left you will see the project explorer (if its not visible, hit ctrl+R).
Expand the items and browse to where it says Project(your document name)- "Microsoft Word Objects" - "ThisDocument"

double click "ThisDocument" and paste the following code. change "Doc3.doc" to your document's name.
save the document and close it. the next time you open it, the standard toolbar will be missing. opening a new doc or switching to another document will make the toolbar appear, switching back to Doc3 will disable the toolbar again

--------------------
Dim WithEvents wApp As Word.Application

Private Sub Document_Open()
Set wApp = Application
Application.CommandBars("Standard").Enabled = False
End Sub

Private Sub wApp_DocumentChange()
Application.CommandBars("Standard").Enabled = IIf(ActiveDocument.Name = "Doc3.doc", 0, 1)
End Sub

Private Sub Document_Close()
Application.CommandBars("Standard").Enabled = True
End Sub
---------------------

Rajesh
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Do you ever need to create a 20 page Word document for some testing purpose? Are you tired of copying & pasting old boring "lorem ipsum" text over and over again, increasing font size and line space in order to make the document 20+ pages long? Look…
Microsoft Word is a program we have all encountered at some point, but very few of us have dug deep into its full scope of features, let alone customized it to suit our needs. Luckily making the ribbon (aka toolbar, first introduced in Word 2007) wo…
This video shows and describes the main difference between both orientations in Microsoft Word. Viewers will understand when to use each orientation and how to get the most out of them.
This Micro Tutorial well show you how to find and replace special characters in Microsoft Word. This is similar to carriage returns to convert columns of values from Microsoft Excel into comma separated lists.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now