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 / August 2006

Tip: Looking for answers? Try searching our database.

Foolproof way to add toolbar button for .dot file

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
RB Smissaert - 02 Aug 2006 21:57 GMT
Is there a foolproof way to make a global template file, a .dot file, add a
button to the standard Word toolbar, the one with File, Edit etc.

I have seen and tried many suggestions, such as putting the code that adds
the button in:
- an AutoOpen Sub
- an AutoExec Sub
- the Document_Open event
- Just adding the button manually and saving the .dot file
with the added button.

The last one was the only one that seemed to work, but when I altered the
location of the .dot file from the
Startup folder in C:\Program Files\ etc. to the one under Documents and
Settings it didn't work anymore.

Surely, there must be same place to put the code so it will run when the
.dot file opens/loads.

RBS
Jean-Guy Marcil - 03 Aug 2006 06:43 GMT
RB Smissaert was telling us:
RB Smissaert nous racontait que :

> Is there a foolproof way to make a global template file, a .dot file,
> add a button to the standard Word toolbar, the one with File, Edit
[quoted text clipped - 11 lines]
> Startup folder in C:\Program Files\ etc. to the one under Documents
> and Settings it didn't work anymore.

All of the above will work.. depending on what the said button does (and its
scope/life expectancy).

Do you need the button for all documents/some/always/ etc.

By the way, as soon as you move a template away from the start-up folder, it
ceases to be a global template (or add-in). The code/custom toolbars it
contains will work only when you create documents based on that template.
Also, AutoOpen and Document_Open  are the same, it is just that the former
is deprecated.
Finally, if the code that creates the button is in a Document_Open sub, it
will not get executed when creating  a document based on this template. For
this, you need to use Document_New.

So, in short, without you telling us more on your purpose and environment,
it is difficult to suggest a "foolproof" way.

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

RB Smissaert - 03 Aug 2006 07:07 GMT
OK, let me explain a bit more.
The purpose of this .dot file is to get data from an Interbase database and
put that data in the ActiveDocument.
The button on the toolbar will launch a Userform that is the interface to
get this data. This Userform will either be a login form when there is no
connection to the database yet or the actual form that sets the parameters
to get the data from Interbase.
So, I am not interested in formats etc. or base the produced document on
that
.dot file.
I suppose I could keep it simple and tell the user to run the macro that
adds
this button via Tools, Macro, Macros, but that is not very neat.

It seems .dot files are not as simple as Excel .xla files.

RBS

> RB Smissaert was telling us:
> RB Smissaert nous racontait que :
[quoted text clipped - 31 lines]
> So, in short, without you telling us more on your purpose and environment,
> it is difficult to suggest a "foolproof" way.
Jonathan West - 04 Aug 2006 08:47 GMT
> OK, let me explain a bit more.
> The purpose of this .dot file is to get data from an Interbase database
[quoted text clipped - 12 lines]
>
> It seems .dot files are not as simple as Excel .xla files.

From this, it would appear that you want the button permanently available
irrespective of what documents (if any) are open)

If that is the case, I would put the macro and the userfrorm into a .dot
file together, put a toolbar into the same dot file and the button on the
toolbar, and have the .dot file automatically loaded as an add-in when Word
starts, by placing the file in Word's Startup folder.

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org

RB Smissaert - 04 Aug 2006 13:37 GMT
Yes, button should always be available.
Yes, the Sub run by the button and the userform are in the .dot file.
Yes, the .dot file is in the Word Startup folder, in this case the one under
Program Files.

Not sure why I need a toolbar. Can't I just put a single button on the Word
Menu Bar?
I think I have solved this in any case as I have made a simple installer
based on a .doc file
that copies all the files to the right folder, installs the template and
puts the button on the
Word Menu Bar. Once the button is there Normal.dot will keep it there.

Still not sure though why the .dot file can't put that button there.

RBS

>> OK, let me explain a bit more.
>> The purpose of this .dot file is to get data from an Interbase database
[quoted text clipped - 21 lines]
> toolbar, and have the .dot file automatically loaded as an add-in when
> Word starts, by placing the file in Word's Startup folder.
Jonathan West - 04 Aug 2006 13:46 GMT
> Yes, button should always be available.
> Yes, the Sub run by the button and the userform are in the .dot file.
[quoted text clipped - 3 lines]
> Not sure why I need a toolbar. Can't I just put a single button on the
> Word Menu Bar?

You can, but if the user has Adobe Acrobat installed, the Acrobat add-in
will chew up your button unless you take special measures.

> I think I have solved this in any case as I have made a simple installer
> based on a .doc file
> that copies all the files to the right folder, installs the template and
> puts the button on the
> Word Menu Bar. Once the button is there Normal.dot will keep it there.

Until the user changes or loses normal.dot.

> Still not sure though why the .dot file can't put that button there.

Well, it can, but I wouldn't advise it.

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org

RB Smissaert - 04 Aug 2006 14:38 GMT
OK, good points indeed.
Are you saying that a toolbar is less likely to be affected
by other apps than a single button?
How should the .dot file put the toolbar there?

RBS

>> Yes, button should always be available.
>> Yes, the Sub run by the button and the userform are in the .dot file.
[quoted text clipped - 18 lines]
>
> Well, it can, but I wouldn't advise it.
Jonathan West - 04 Aug 2006 15:04 GMT
> OK, good points indeed.
> Are you saying that a toolbar is less likely to be affected
> by other apps than a single button?

Correct.

> How should the .dot file put the toolbar there?

Create it manually in the .dot.

Before you create the toolbar and put the button into it using the Tools
Customize dialog, make sure that you set the "Save changes in" dropdown at
the bottom of the dialog to your template.

Make sure the toolbar is visible when you save the file. It should reappear
when the .dot is loaded as an add-in.

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org

RB Smissaert - 04 Aug 2006 16:01 GMT
OK, I understand now.
This .dot file has a toolbar, just like Normal.dot has the regular Word Menu
Bar etc.
Thanks for clearing this up.

RBS

>> OK, good points indeed.
>> Are you saying that a toolbar is less likely to be affected
[quoted text clipped - 12 lines]
> Make sure the toolbar is visible when you save the file. It should
> reappear when the .dot is loaded as an add-in.
RB Smissaert - 05 Aug 2006 00:22 GMT
Nearly done this now.
Can't figure out though to get my new toolbar appearing after the standard
toolbar.
I can make it appear as the first toolbar on that row or the last (by making
left > 0)
but can't get it after the standard toolbar.

RBS

> Is there a foolproof way to make a global template file, a .dot file, add
> a button to the standard Word toolbar, the one with File, Edit etc.
[quoted text clipped - 16 lines]
>
> RBS
Jonathan West - 07 Aug 2006 13:34 GMT
> Nearly done this now.
> Can't figure out though to get my new toolbar appearing after the standard
> toolbar.
> I can make it appear as the first toolbar on that row or the last (by
> making left > 0)
> but can't get it after the standard toolbar.

Read the RowIndex properties of the standard toolbars, and then set the
RowIndex of your custom toolbar to 1 more than the highest of the ones you
want it to below.

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org

RB Smissaert - 07 Aug 2006 14:29 GMT
I want it to appear on the same row as the standard toolbar, so if the
formatting
toolbar is present than I want it in between the standard toolbar and the
formatting toolbar.
So, all on the same row.
It looks making the rowindex one higher as you sugggest would make it appear
below the
row holding the standard toolbar. I don't want that as it would make the
document workspace smaller.

RBS

>> Nearly done this now.
>> Can't figure out though to get my new toolbar appearing after the
[quoted text clipped - 6 lines]
> RowIndex of your custom toolbar to 1 more than the highest of the ones you
> want it to below.
Jonathan West - 07 Aug 2006 15:01 GMT
>I want it to appear on the same row as the standard toolbar, so if the
>formatting
[quoted text clipped - 5 lines]
> row holding the standard toolbar. I don't want that as it would make the
> document workspace smaller.

In that case, work out the Rowindex of the toolbar you want it next to, set
the Rowindex of your toolbar to be the same.

To make sure that your toolbar is to the right of a toolbar, set its Left
property to some value greater than the sum of the Left and Width properties
of the toolbar you are positioning relative to.

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org

bart.smissaert@gmail.com - 07 Aug 2006 16:01 GMT
Thanks, had tried that already, but had made the fundamental mistake to
measure
the left position after adding the new toolbar.
Should of course take the left before adding the toolbar and maybe now
it should
be OK.

RBS

> >I want it to appear on the same row as the standard toolbar, so if the
> >formatting
[quoted text clipped - 19 lines]
> Please reply to the newsgroup
> Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
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.