Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2006

Tip: Looking for answers? Try searching our database.

Using Auto macros to Protect Toolbar

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Alex - 06 Feb 2006 21:35 GMT
Cindy M. was helping me in another newsgroup on this, but I thought I should
move my quesion here, to a more appropriate category.

I'm still trying to protect a toolbar from being turned off by users,
regardless of the template they use to create a document in Word.  I have put
the following code in the Normal project in VBA:

Sub AutoNew()
CommandBars("IPG").Visible = True
CommandBars("IPG").Protection = msoBarNoChangeVisible
End Sub

Sub AutoOpen()
CommandBars("IPG").Visible = True
CommandBars("IPG").Protection = msoBarNoChangeVisible
End Sub

It seems to be working, regardless of the template that is used.  I would
have thought that this code would only work for documents created using the
normal.dot template.  Why is it working, even if a user creates a new
document using, for example, RequestForm.dot?

My other question is that the above code is working for every document
except for Document.1 that is automatically created when Word opens.  I can't
seem to get the above code to work in Sub AutoExec(), which I think would
take care of the Document1.doc.  Will the above code not work in AutoExec().  
Thanks for continued help on this - I'm getting closer. : )
Tony Jollans - 07 Feb 2006 13:23 GMT
If you have the code in the Normal Template, by default the customization
affects everything which doesn't have its own explicit overriding
customization. To only affect individual documents, or documents based on a
particular template, place the code in the document, or template, and set
CustomizationContext accordingly.

Your code will run whenever a document based on Normal is created (except,
as you note, for the default document created at startup) or opened. It will
not run when other documents are created or opened. However, once it has
run, you have the toolbar whatever you open or create later.

You should probably be putting the code in the template you want it to
affect (but still set CustomizationContext) and also removing the toolbar on
close. As I don't know exactly when you want the toolbar displayed and not,
I can't be more precise.

--
Enjoy,
Tony

> Cindy M. was helping me in another newsgroup on this, but I thought I should
> move my quesion here, to a more appropriate category.
[quoted text clipped - 23 lines]
> take care of the Document1.doc.  Will the above code not work in AutoExec().
> Thanks for continued help on this - I'm getting closer. : )
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.