Attached template save issue

N

Ness

I have an attached template that i send all the autotext entries out to the
attached template from the normal on exit (as our normal template is
protected). The ony problem I have is that it asks to save this template.
I want it to exit without asking for the save.
My code is below:
If Windows.Count = 1 Then
Application.ScreenUpdating = False
For Each atentry In _
ActiveDocument.AttachedTemplate.AutoTextEntries
Application.OrganizerCopy _
Source:=ActiveDocument.AttachedTemplate.FullName, _
Destination:="c:\autotext.dot", Name:=atentry.Name, _
Object:=wdOrganizerObjectAutoText
Next atentry
End If

activedocument.save


Please help!
 
C

Charles Kenyon

Attached template or global template?
It appears that AutoText.dot is a global template.

Normal.dot should not be shared or protected.

If saving to the global template you need to add code to save the changes to
that template if you don't want your user prompted for that.
--
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.
 
N

Ness

I am saving from the global template(normal.dot) autotext entries into an
attached template (autotext.dot). We have a standardised global template
which can not be saved for business reasons, so we save out individuals
autotext to a file located in their profile.

Can you help?
 
J

Jean-Guy Marcil

Ness was telling us:
Ness nous racontait que :
I have an attached template that i send all the autotext entries out
to the attached template from the normal on exit (as our normal
template is protected). The ony problem I have is that it asks to
save this template. I want it to exit without asking for the save.
My code is below:
If Windows.Count = 1 Then
Application.ScreenUpdating = False
For Each atentry In _
ActiveDocument.AttachedTemplate.AutoTextEntries
Application.OrganizerCopy _
Source:=ActiveDocument.AttachedTemplate.FullName, _
Destination:="c:\autotext.dot", Name:=atentry.Name, _
Object:=wdOrganizerObjectAutoText
Next atentry
End If

activedocument.save

From this code I gather that you are copying entries from the attached
template (Normal.dot I presume) to a template named autotext.dot.

autotext.dot does not seem to be a global template because C:\ is not
normally assigned as a start-up folder (Global template are stored in the
start up folder as defined in the File locations tab of Options... under the
Tools menu).

In any case, as is, your code will automatically save changes to
autotext.dot every time it adds an "atentry" to it. So, no need to
explicitely save it.
The problem is that autotext.dot (because it does not seem to be a global
template) will not be available in Word, so its autotext entries will not be
available either...

You should make sure that autotext.dot is in the start-up folder, and then
use code like:

Sub Test()
Dim StartupPath As String
Dim AutoTextTemplate As Template
Dim atEntry As AutoTextEntry

Const AutoTemp As String = "autotext.dot"
StartupPath = Application.Options.DefaultFilePath(wdStartupPath) _
& Application.PathSeparator

Set AutoTextTemplate = Templates(StartupPath & AutoTemp)

If Windows.Count = 1 Then
Application.ScreenUpdating = False
For Each atEntry In _
ActiveDocument.AttachedTemplate.AutoTextEntries
Application.OrganizerCopy _
Source:=ActiveDocument.AttachedTemplate.FullName, _
Destination:=AutoTextTemplate.FullName, Name:=atEntry.Name, _
Object:=wdOrganizerObjectAutoText
Next atEntry
End If

AutoTextTemplate.Save

End Sub


--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
N

Ness

Thank you Jean - you have worked out what is doing but not quite what I need.
The autotext.dot is loaded in the normal.dot autoexec. It is not in the Word
startup folder as we have had various office versions and some machines
having multiple installations! hence why I have inherited this legacy
location of c:\ for the autotext template.
It all works well but on exit of Word (the script I supplied is in the
Autoclose script for the global(normal) template it requests if I wish to
save the autotext file. It is this I wish to stop.

Thanks for you previous reply.

Regards
 
J

Jean-Guy Marcil

Ness was telling us:
Ness nous racontait que :
Thank you Jean - you have worked out what is doing but not quite what
I need. The autotext.dot is loaded in the normal.dot autoexec. It is
not in the Word startup folder as we have had various office versions
and some machines having multiple installations! hence why I have
inherited this legacy location of c:\ for the autotext template.
It all works well but on exit of Word (the script I supplied is in the
Autoclose script for the global(normal) template it requests if I
wish to save the autotext file. It is this I wish to stop.

Use the same kind of code that you use to load the autotext.dot in the
autoexec module. Instead of loading, unload it and save it at the same time.

If you need help, post the code you use to load the file (so as to make sure
that we re talking about the same critter!).

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
N

Ness

Jean,
many thanks for your help and apologie sabout delay in response. I load the
autotext file via the autoexec module - code below:
Dim fs
Set fs = CreateObject("Scripting.FileSystemObject")

checkc = fs.fileexists("c:\autotext.dot")
If checkc = True Then
AddIns.Add ("c:\autotext.dot"), Install:=True
Else: MsgBox "You are missing your autotext file!" & vbCrLf & vbCrLf
& _
"Please contact Technology if this is needed.", vbInformation,
"Template Information"
End If

Do you mean to load the autotext file when closing and save at that time?
How do I save the attached template? I have tried a few methods but to no
avail.

Cheers

Elliot.
 

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