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 / October 2005

Tip: Looking for answers? Try searching our database.

Attached template save issue

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ness - 05 Oct 2005 14:49 GMT
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!
Charles Kenyon - 05 Oct 2005 15:03 GMT
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.
Signature

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

See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
--------- --------- --------- --------- --------- ---------
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.

>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
[quoted text clipped - 15 lines]
>
> Please help!
Ness - 05 Oct 2005 15:15 GMT
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?

> Attached template or global template?
> It appears that AutoText.dot is a global template.
[quoted text clipped - 22 lines]
> >
> > Please help!
Jean-Guy Marcil - 05 Oct 2005 16:23 GMT
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
[quoted text clipped - 13 lines]
>
> 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

Signature

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

Ness - 05 Oct 2005 16:48 GMT
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

> Ness was telling us:
> Ness nous racontait que :
[quoted text clipped - 60 lines]
>
> End Sub
Jean-Guy Marcil - 06 Oct 2005 20:28 GMT
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
[quoted text clipped - 4 lines]
> 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!).

Signature

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

Ness - 12 Oct 2005 10:05 GMT
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.

> 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
[quoted text clipped - 15 lines]
>
> Please help!
 
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.