Discussion:
add-in associated with .dot file (only)
(too old to reply)
Bob Eaton
2006-07-04 06:52:41 UTC
Permalink
Is it possible to associate an add-in with a document template so that it
only loads if the document template is attached (i.e. via "Tools",
"Templates and Add-ins")?

I have an add-in I've made, but I don't want it loaded always. Only when I
want it to be added.

Also, the website I got help from in creating the add-in (in C#:
http://www.codeproject.com/csharp/wordaddinpart1.asp) suggested
redistributing a template into which you can add your menu items (since
another add-in may change the CustomizationContext and clobbered your
add-in's menus).

If it's not possible to associate an add-in with a document template to be
loaded only when the document template is attached, then what other
alternatives are there for not loading it at "host application startup"?

That is, I used the extensibility wizard in VS.Net 2005 to create this
"shared
add-in", and one of the questions was "Do you want it to start when the host
application starts". I said "yes", but what I really want is "no". If I say,
"no", however, it's not clear to me how to manually add an "add-in".

I know if I go to "Tools", "Templates and Add-in", it's easy enough to add a
document template (thus my first question above), but for "Add-ins", it's
looks like it's looking for a ".wll" extention file. But my shared add-in
has a .dll extension!?

I'm sure it's something obvious, but I can't seem to find it in the
documentation.

Thanks in advance,
Bob
Cindy M -WordMVP-
2006-07-04 13:05:42 UTC
Permalink
Hi Bob,

You should be able to set a reference to your addin in the
template
(Tools/References). That ought to load the Addin into
memory and make the
Addin's code accessible, so that VBA code in the template
can call procedures.

One a document is created from a template, or opened
attached to the template,
Document_New or Document_Open fire and you can have code in
them that call
Addin procedures (to display toolbars, for example).
Depending on how you use
CustomizationContext, these commandBar objects'
availability can be limited to
just the document (or the template).

So, from what I glean from your problem description, yes,
you should probably
distribute a template with your solution. It will need a
reference to your
add-in, and such references are folder-related. Install
probably should use a
specific file path for the assembly and not let the user
change it, or put it
in System32 folder. The template would need to go in the
user's User Template
folder location.

to COM Addins, in general: there's "always load" and then
there's "load on
demand". If your Addin installs for the user, only (rather
than the machine),
then it's more visible for the user, but in either case:

In Word: Tools/Customize/Commands. Select the "tools"
category, then pull COM
Add-ins to the Tools menu. Close the dialog box. Now
execute the command. All
COM Add-ins loaded for the user (not the machine) should be
listed here. Plus
the "Add" button can be used to browse and load any Addin
available on the
machine. Once it's been placed in the list, the user should
be able to
load/unload at will using the checkbox (as long as it's a
"load on demand"
add-in; if it's an auto load that's been deactivated,
selecting it through
this method reactivates autoload).
Post by Bob Eaton
Is it possible to associate an add-in with a document
template so that it
Post by Bob Eaton
only loads if the document template is attached (i.e. via
"Tools",
Post by Bob Eaton
"Templates and Add-ins")?
I have an add-in I've made, but I don't want it loaded
always. Only when I
Post by Bob Eaton
want it to be added.
Also, the website I got help from in creating the add-in
http://www.codeproject.com/csharp/wordaddinpart1.asp)
suggested
Post by Bob Eaton
redistributing a template into which you can add your
menu items (since
Post by Bob Eaton
another add-in may change the CustomizationContext and
clobbered your
Post by Bob Eaton
add-in's menus).
If it's not possible to associate an add-in with a
document template to be
Post by Bob Eaton
loaded only when the document template is attached, then
what other
Post by Bob Eaton
alternatives are there for not loading it at "host
application startup"?
Post by Bob Eaton
That is, I used the extensibility wizard in VS.Net 2005
to create this
Post by Bob Eaton
"shared
add-in", and one of the questions was "Do you want it to
start when the host
Post by Bob Eaton
application starts". I said "yes", but what I really want
is "no". If I say,
Post by Bob Eaton
"no", however, it's not clear to me how to manually add
an "add-in".
Post by Bob Eaton
I know if I go to "Tools", "Templates and Add-in", it's
easy enough to add a
Post by Bob Eaton
document template (thus my first question above), but for
"Add-ins", it's
Post by Bob Eaton
looks like it's looking for a ".wll" extention file. But
my shared add-in
Post by Bob Eaton
has a .dll extension!?
I'm sure it's something obvious, but I can't seem to find
it in the
Post by Bob Eaton
documentation.
Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update
Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any
follow question or
reply in the newsgroup and not by e-mail :-)
Bob Eaton
2006-07-05 02:41:45 UTC
Permalink
Thanks Cindy for you response,

The one answer you gave about "COM Add-ins" was the key: going in thru
"Templates and Add-ins" doesn't give you the *COM* add-ins...

I wonder why COM Add-ins isn't just another tab in that "Templates and
Add-ins" dialog box?

Also, you suggested that since the add-in is a COM object (duh!), I can call
it from template VBA code... I hadn't realized that and that solves my
problem exactly!

Thanks,
Bob
Post by Cindy M -WordMVP-
Hi Bob,
You should be able to set a reference to your addin in the
template
(Tools/References). That ought to load the Addin into
memory and make the
Addin's code accessible, so that VBA code in the template
can call procedures.
One a document is created from a template, or opened
attached to the template,
Document_New or Document_Open fire and you can have code in
them that call
Addin procedures (to display toolbars, for example).
Depending on how you use
CustomizationContext, these commandBar objects'
availability can be limited to
just the document (or the template).
So, from what I glean from your problem description, yes,
you should probably
distribute a template with your solution. It will need a
reference to your
add-in, and such references are folder-related. Install
probably should use a
specific file path for the assembly and not let the user
change it, or put it
in System32 folder. The template would need to go in the
user's User Template
folder location.
to COM Addins, in general: there's "always load" and then
there's "load on
demand". If your Addin installs for the user, only (rather
than the machine),
In Word: Tools/Customize/Commands. Select the "tools"
category, then pull COM
Add-ins to the Tools menu. Close the dialog box. Now
execute the command. All
COM Add-ins loaded for the user (not the machine) should be
listed here. Plus
the "Add" button can be used to browse and load any Addin
available on the
machine. Once it's been placed in the list, the user should
be able to
load/unload at will using the checkbox (as long as it's a
"load on demand"
add-in; if it's an auto load that's been deactivated,
selecting it through
this method reactivates autoload).
Post by Bob Eaton
Is it possible to associate an add-in with a document
template so that it
Post by Bob Eaton
only loads if the document template is attached (i.e. via
"Tools",
Post by Bob Eaton
"Templates and Add-ins")?
I have an add-in I've made, but I don't want it loaded
always. Only when I
Post by Bob Eaton
want it to be added.
Also, the website I got help from in creating the add-in
http://www.codeproject.com/csharp/wordaddinpart1.asp)
suggested
Post by Bob Eaton
redistributing a template into which you can add your
menu items (since
Post by Bob Eaton
another add-in may change the CustomizationContext and
clobbered your
Post by Bob Eaton
add-in's menus).
If it's not possible to associate an add-in with a
document template to be
Post by Bob Eaton
loaded only when the document template is attached, then
what other
Post by Bob Eaton
alternatives are there for not loading it at "host
application startup"?
Post by Bob Eaton
That is, I used the extensibility wizard in VS.Net 2005
to create this
Post by Bob Eaton
"shared
add-in", and one of the questions was "Do you want it to
start when the host
Post by Bob Eaton
application starts". I said "yes", but what I really want
is "no". If I say,
Post by Bob Eaton
"no", however, it's not clear to me how to manually add
an "add-in".
Post by Bob Eaton
I know if I go to "Tools", "Templates and Add-in", it's
easy enough to add a
Post by Bob Eaton
document template (thus my first question above), but for
"Add-ins", it's
Post by Bob Eaton
looks like it's looking for a ".wll" extention file. But
my shared add-in
Post by Bob Eaton
has a .dll extension!?
I'm sure it's something obvious, but I can't seem to find
it in the
Post by Bob Eaton
documentation.
Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update
Jun 17 2005)
http://www.word.mvps.org
This reply is posted in the Newsgroup; please post any
follow question or
reply in the newsgroup and not by e-mail :-)
Cindy M -WordMVP-
2006-07-05 09:04:39 UTC
Permalink
Hi Bob,
Post by Bob Eaton
The one answer you gave about "COM Add-ins" was the key: going in thru
"Templates and Add-ins" doesn't give you the *COM* add-ins...
I wonder why COM Add-ins isn't just another tab in that "Templates and
Add-ins" dialog box?
Also, you suggested that since the add-in is a COM object (duh!), I can call
it from template VBA code... I hadn't realized that and that solves my
problem exactly!
Glad part of my musing was on target :-)

The Templates and Add-ins dialog box existed long before COM Add-ins came on
the scene (Word 2000). For a decade, the only kinds of Add-ins Word recognized
were templates or wll files (created in something like C++).

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :-)

Loading...