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

Open file with a Custom Toolbar

Status
Not open for further replies.

cwash

Technical User
May 27, 2002
45
US
is it possible to have a word file always open with it's custom toolbar, even if the file is opened on different pc's?

i want my custom toolbar to be the only toolbar to be used and shown on my file no matter who opens or where my file is opened...is this possible.

if so...please let me know.

tia,
c

 
Toolbars are stored in templates. To be able to include a custom Toolbar around the office, you need to save the toolbar to a template and then place it centrally on the server in a folder called (preferably) Global Startup. In Tools, Options, File Locations, make sure that Startup is pointing at this new folder.

If you don't have a network, then you need to save the Toolbar to a new template, transport the template to the other computer and then use Organiser to copy the Toolbar to that computers normal.dot. The Toolbar will then always be available.


Regards: tf1
 
tf1 - not completely correct.

Yes, they are stored in templates.

Yes, to have it on a another computer you have to have that template on that computer.

But the the reference to normal.dot is WRONG. This is standard Microsoft narrow focus.

All that is required is the template, and Word's awareness of it. Period. Copying the template into either the User template folder, or the Workgroup folder will work fine. It will even work having the template is some other folder, as long as there is an AutoOpen (or Document_Open) routine that explicitly attaches the template file to the opening document. That file can be ANYWHERE.

To suggest that styles, code, or anything else should be moved to normal.dot is bad advice. In fact, in my classes I teach to NEVER put anything you really need into normal.dot. Do not put Autotext, macros, styles...anything into normal.dot. Even Microsoft itself acknowledges that the many many read/writes to normal.dot cause it to get corrupt. What is the most common advice with troubleshooting Word? Delete normal.dot.

Do not need to use Organizer to copy anything. Send the template file along with the document. If they are in the same folder (or will be), then add this into the ThisDocument module.

Code:
Sub Document_Open()
ActiveDocument.AttachedTemplate = "TemplateFileName.dot"
End Sub

As long as the template file is in the same folder as the document, the customize toolbar will (or should!) will be available.


Gerry
 
Gerry,

Are you suggesting that I save my 'main' document, the one i want with its own custome toolbar,
1- as a "save as" template
2- save template in a folder
3- save my 'main' document in the folder with the newly created template
4- create a custom toolbar to be attached to the new template

You mentioned "AutoOpen (or Document_Open)", what do I do with this, where does it go, and what is the language for "AutoOpen".

Thanks again,
c

 
I not sure I follow you.

Templates are special design documents. All "real" document (ie. those with .DOC extensions) are based on templates. Every one. Youn can not have a document based on NO template. If you are not explicitly using one, then Word explicitly uses one for you - the default, normal.dot.

Document templates have a .DOT extension.

Templates are used to clone themselves. If you do nothing, then Word, in fact clones, normal.dot. This creates a new document (blank), because normal.dot is is blank.

What I am suggesting is if you want a custom toolbar to follow a document around, create the document from a template, and send the template with the document.

Now, as stated, normal.dot is the default, and you do NOT want to be sending your normal.dot around.

So, therefore:
[ol]
[li]If you are not using templates, start now.[/li]
[li]Templates are, generally, generic enough that they can easily be reused.[/li]
[li]Fully flow out your design. Since you state you want only your toolbar to show, I am assuming you know how to handle commandbars, and commandbar controls. Be sure you know how to create and release objects.[/li]
[li]create everything in a document that, yes, SaveAs a Document Template. Note where the file location is - is different than the normal file save as .DOC location. This is important[/li]
[li]Select File, New (do NOT open the template file unless you are editing the template itself; do NOT use the New button on the toolbar) and select Document to make from your template file.[/li]
[li]Hopefully you are using styles; if so, they will all be carried along with the document cloned from your template.[/li]
[li]In the ThisDocument module of the template file, write the Document_Open code.[/li]
[li]the point is to have some else see your custom toolbar - yes? The answer is that they must have the file and the template that holds the custom toolbar together in the same folder, at least for the code to work. They could be in different folder - that is, what ever the OTHER person has set up for Word. But you don't always know that, now do you? So the point, again, is that the OTHER person keeps the template and the document in the same folder. The toolbar will be there.[/li]
[/ol]

To get to the ThisDocument code module, press Alt-F11 to get the Visual Basic Editor, press Ctrl-R to get the Project Explorer, and then like Windows explorer expand sub items with a plus sign. Under Microsoft Word Object you will find ThisDocument. Click the upper left dropdown to get "Document", clcik upper right dropdown to get Document_Open. Dump the code in there.

It is hard to know what to write here. You are asking about forcing an interface (using ONLY your own toolbar), yet also asking about where to put ThisDocument code. On the first hand is a relatively complex task - not hugely complex to put a custom toolbar up, but complex enough if you are going FORCE it upon a user. On the other hand is a very simple task.

So I hope you do not get offended if I wrote too much detail. As other know here....I tend to blather...

Gerry
 
Gerry

I won't disagree with you: my approach was the MS way - mainly to keep it simple.

I don't keep anything in my normal.dot either. I keep all my templates in Startup (on the server at work and locally at home). This included separate templates for different types of AutoText, Toolbars, etc. As well as keeping the templates smaller (faster loading), it makes updating and managing so much easier.

I am a great believer in keeping normal.dot as small and uncustomised as possible. Word just seems to perform better that way.



Regards: tf1
 
Gentlemen,

Wouldn't it be a lot easier to store the toolbar in the Document itself instead of a Template?

Obviously code will still be needed in Document_Open to suppress other toolbars (and in Document_Close to reinstate them) and if this code is in the document rather than a template, the user will be prompted to enable macros.

Of course forcing an interface on a user is no mean feat - they can easily reinstate toolbars manually; it's pretty involved stopping them and, personally, I don't think you should be doing it.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
 
Absolutely. Hmmm, I certainly did not want to be seen to be encouraging forcing an interface. I have gone that route and;

1. It ain't as easy as it is in the movies

2. It falls apart when someone really wants it to.

So, I guess I got involved with the possibilities of the question. Design-wise, unless there is a REAL reason, forcing an interface is not a great path. However, the original question was how to carry a customized toolbar along. Yes I know the question have the "only" word.

Tony is, quite rightly the voice of reason. Again.

Gerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top