Re-Define NormalTemplate

R

Ridge Kennedy

Dear All,

Office 2003 on XP workstations.

I've run into this before and spent lots of time fumbling before resorting
to the organizer and moving things manually.

I want to do something via code -- in this case add AutoText entries to a
template. I want to do this programmatically, so we can update the list
easily.

I do not want add them to normal.dot -- rather to an AddIn.dot. But I get
errors galore when I try to set NormalTemplate as a different template. I've
searched for samples using some different template, and haven't found one.
A small push in the right direciton would be very helpful.

Sincerely,

Ridge (in New Joisey)
 
J

Jonathan West

Ridge Kennedy said:
Dear All,

Office 2003 on XP workstations.

I've run into this before and spent lots of time fumbling before resorting
to the organizer and moving things manually.

I want to do something via code -- in this case add AutoText entries to a
template. I want to do this programmatically, so we can update the list
easily.

I do not want add them to normal.dot -- rather to an AddIn.dot. But I get
errors galore when I try to set NormalTemplate as a different template.
I've searched for samples using some different template, and haven't found
one. A small push in the right direciton would be very helpful.

You can't change the filename pointed to by NormalTemplate object, the
property is read-only

You can use the Organizer programmatically.

Alternatively, you can use the AutoTextEntries.Add method for any template
or add-in that you have loaded, if you are creating new autotext entries
rather than moving them between documents


--
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
 
C

Charles Kenyon

Don't know why your are trying to set NormaTemplate to be a different
template. You definitely do _not_ want to be doing this. You can add your
template as an Add-in very easily, using code or by putting it in the User's
Word Startup folder. See http://addbalance.com/word/movetotemplate.htm for
step-by-step instructions on moving / sharing / copying / backing-up
customizations including AutoText, AutoCorrect, keyboard assignments,
toolbars, macros, etc.
--

Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide


--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
R

Ridge Kennedy

Johathan said:
Alternatively, you can use the AutoTextEntries.Add method for any template
or add-in that you have loaded, if you are creating new autotext entries
rather than moving them between documents

That's what I want to do. Looks like there is an AttachedTemplate property
that I need.

so, something like this?

dim MyTemplate as object
dim strNewAutoText as string

' do stuff to get my text in strAutoText

' identify the target template
ActiveDocument.AttachedTemplate = DriveSpec:\path\MyTemplate.doc

' set MyTemplate as the target template
set MyTemplate = ActiveDocument.AttachedTemplate

'to add an entry
MyTemplate.AutoTextEntries.Add Name:= strAutoText, Value:= strAutoText
 
J

Jonathan West

Ridge Kennedy said:
Johathan said:


That's what I want to do. Looks like there is an AttachedTemplate property
that I need.

so, something like this?

dim MyTemplate as object
dim strNewAutoText as string

' do stuff to get my text in strAutoText

' identify the target template
ActiveDocument.AttachedTemplate = DriveSpec:\path\MyTemplate.doc

' set MyTemplate as the target template
set MyTemplate = ActiveDocument.AttachedTemplate

'to add an entry
MyTemplate.AutoTextEntries.Add Name:= strAutoText, Value:= strAutoText

Yes, something like that would do. However, it might be better to load the
template by adding it to the AddIns collection. All add-ins are also members
of the Templates collection, and you can identify them as such. Something
like this

Addins.Add FileName:="DriveSpec:\path\MyTemplate.dot", Install=True
Set myTemplate = Templates("DriveSpec:\path\MyTemplate.dot")
MyTemplate.AutoTextEntries.Add Name:= strAutoText, Value:= strAutoText

Then at the end, you can do this

MyTemplate.Save
Set myTemplate = Nothing
Addins("DriveSpec:\path\MyTemplate.dot").Installed = False
Addins("DriveSpec:\path\MyTemplate.dot").Delete

This saves the changes in the template, unloads it and removes it from the
list of addins.

--
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
 
C

Charles Kenyon

Nope, AttachedTemplate is the attached template, not a template that is
loaded as an Add-In.
You can only have one attached template. You can have many Add-Ins. For more
on the different kinds of templates, tabs on the file new dialog, and
locations of templates folders see
http://addbalance.com/usersguide/templates.htm.

If you want to be able to add AutoText to an Add-In the simple way is to
create the AutoText and save it to your template making sure that it is
going to your template. You can't do this with Shift-F3, you need to use the
AutoText dialog and specify the location. (Note, the location you specify
here sticks for the remainder of your Word session and limits not only where
AutoText goes but where Word looks for AutoText.) This is simple for you to
do. It isn't simple to train a user to do it. Especially not bulk users.
Also, if you actually share a single AutoText Add-In, the first person to
start Word will put a lock on the Add-In file. No one else will be able to
edit it. The preferred method to distribute Add-Ins is to put the file on
the network and have it copied to a local file upon login for use as a local
file.

Do you want you or one designated person per office to add AutoText but to
have everyone able to use it? If so that will work. If you want everyone to
be able to edit AutoText in your Add-In that adds a whole layer of
complexity and security. (If someone can edit, they can delete.) I'm not
sure it is possible. I've just had people email me documents containing the
AutoText they want added with a suggested name.
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide


--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
R

Ridge Kennedy

Johathan, being extremely helpful, said:
Yes, something like that would do. However, it might be better to load the
template by adding it to the AddIns collection.

The advantages being, maybe a little more efficient code and more control
over loading/unloading, memory use, etc.?

When I put a template in the startup directory for an enduser, am I
automatically making it a part of the AddIns collection? Or is it part of
the Templates collection? Or both?? (My money's on "both" at the moment.)

R.


All add-ins are also members
 
C

Charles Kenyon

Both. Note that you want it in the Word startup folder rather than the
Office startup folder if you want to share macros. Word loads templates from
both locations into the Templates collection but only those in Word's
startup folder can be automatically cleared by macro security.
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide


--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
J

Jonathan West

The advantages being, maybe a little more efficient code and more control
over loading/unloading, memory use, etc.?

When I put a template in the startup directory for an enduser, am I
automatically making it a part of the AddIns collection? Or is it part of
the Templates collection? Or both?? (My money's on "both" at the moment.)

Both - kinda-sorta :)

If you put a template file in the startup folder, it will automatically
become a member of the Addins collection and will be installed as soon as
Word starts. Therefore, you won't need to bother with loading it in the way
I described.

All Addins whose Installed property is True are also members of the
Templates collection. This means that any add-in in the startup folder is
also a member of the templates collection unless you temporarily unload it
by setting the Addin's Installed property to False.


--
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
 
R

Ridge Kennedy

Charles said:
Nope, AttachedTemplate is the attached template, not a template that is
loaded as an Add-In.
You can only have one attached template.

So if you "attach" TemplateX.dot, you are no longer attached to Normal.dot.
Or is Normal.dot a special case.
You can have many Add-Ins. For more on the different kinds of templates,
tabs on the file new dialog, and locations of templates folders see
http://addbalance.com/usersguide/templates.htm.

I'm printing it for study and underlining purposes.
If you want to be able to add AutoText to an Add-In the simple way is to
here sticks for the remainder of your Word session and limits not only
where AutoText goes but where Word looks for AutoText.)

I've run into that while experimenting with this.
Also, if you actually share a single AutoText Add-In

Nope, no way.
We're just starting to tap into this stuff. Goal in this case is to use
netlogon script to copy (if version on server is newer) a template to the
user's Word>Startup folder. I expect it will be read-only.

We're an organization with lots of big member-firms, so my thought, as
something to show value to managment and practicality to endusers, was to
include the top 100 firm names as AutoText entries. Have them bundled by
style. Seemed like it could be useful, and it was an actual request from
some folks working on a special project a while back.

Why automate the process. Firm names change, and so we need to be able to
go back periodically and refresh the list. Probably doesn't have to be done
too frequently, but I do need to be sure it is fairly easy to maintain, if I
try to sell it to the boss.

Thank you all (all you mavens out there) for sharing your time and
expertise.

Sincerely,

Ridge (still in New Joisey)
 
C

Charles Kenyon

Such an AutoText Add-In can be very handy for setting up letterhead and
other forms that hold such information that doesn't change often, but when
it does change it is important. You can put the information in the template
with AutoText Fields and have an AutoNew macro that unlinks the fields upon
document creation. This gives you flexible templates with fixed documents.

For a firm with multiple locations, the local address and information can be
stored in a separate AutoText container (so it doesn't get wiped out by an
update of the firm-wide one).
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide


--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
C

Charles Kenyon

Automating:

Get a copy of Jay Freedman's AutoTextLoader. Puts AutoText into tables for
editing, writes it back as AutoText.
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide


--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top