Word template is being overwritten

N

Nature1911

I created a template in Word 2003. When I open it from the folder in Windows
it forces me to save changes as a new file, which is what it is supposed to
do. But, when I open the template from a link in a PDF document and make
changes, it just overwrites the template. It does not force me to save it
under a new name as a new file.

How can I set it so that each time the template is opened from the link in
the PDF file, I have to change the file name so that the original template
remains unchanged?
 
D

Dawn Crosier, Word MVP

The PDF Link is actually opening the template, which is why the template
is getting overwritten. If you will notice the title bar when you open
from the PDF link, it lists the name of the template itself, rather than
"document1"

What I would do, is add the following code to the template. This will
force the template to always open as a new document.


Private Sub Document_Open()

'this code is for template and prevents
'the user from accidentally opening template
'in development mode...create standard document

'turns off repagination and screen updating
'to allow automation to work faster and
'less chance of template corruption or crashing

Options.Pagination = False
Application.ScreenUpdating = False

Dim intDocumentType
Dim strTemplateName As String
Dim strTemplatePath As String

'The following allows the entire project
'to know which template is being worked with
'and it's path. This prevents from having
'to place the template in a specific
'Word template directory. Both are Globals

'gets the full path/name of the active template
strTemplateName = Templates(1).FullName

'gets Path to Template and pads with "\" if required
strTemplatePath = Templates(1).Path
If Right(strTemplatePath, 1) <> Application.PathSeparator Then
strTemplatePath = strTemplatePath & Application.PathSeparator
End If

intDocumentType = ActiveDocument.Type

'*******************************************
'COMMENT OUT ALL INDENTED CODE BELOW WHEN WORKING
'ON TEMPLATE IN DESIGN MODE OR CHANGES
'WON'T BE PROPERLY SAVED. TURN IT BACK ON
'FOR FINAL SO USER CAN'T ACCIDENTALLY
'ACCESS MASTER TEMPLATE DESIGN
'********************************************

If intDocumentType = 1 Then
Documents.Add Template:=strTemplateName
Documents(strTemplateName).Close SaveChanges:=wdDoNotSaveChanges
End If

End Sub


If you need help with installing the above code, then see
http://pubs.logicalexpressions.com/Pub0009/LPMArticle.asp?ID=166 for
help with getting it installed.

--
Dawn Crosier
Microsoft MVP
"Education Lasts a Lifetime"
This message is posted to a newsgroup. Please post replies and questions
to the newsgroup so that others can learn as well.




I created a template in Word 2003. When I open it from the folder in Windows
it forces me to save changes as a new file, which is what it is supposed to
do. But, when I open the template from a link in a PDF document and make
changes, it just overwrites the template. It does not force me to save it
under a new name as a new file.

How can I set it so that each time the template is opened from the link in
the PDF file, I have to change the file name so that the original template
remains unchanged?

No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.516 / Virus Database: 269.17.11/1201 - Release Date: 12/28/2007 11:51 AM

No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.516 / Virus Database: 269.17.11/1201 - Release Date:
12/28/2007 11:51 AM
 
N

Nature1911

Thanks Dawn,

I plugged in this code, but still didn't get it to work. Also, because so
many people are going to be using this, I don't want to use macros because
many will have them disabled. I'm trying to "dummy-proof" this process.

I don't understand why there is a difference when a template is opened from
a link within a PDF and when it is just opened from a folder. Since the
point of a template is to prevent people from changing the template, why does
it open so the template itself is changed? Is this a bug in Word? Are there
any other options?

Thank you very much!
 
N

Nature1911

Dawn,

Thank you. We got it to work using your code. I am concerned, however. If
users have macros disabled, it won't matter. They could go in and ruin the
template for further use. Are there any other options?

Thanks,
Bryan
 
D

Dawn Crosier, Word MVP

The difference is that Windows or Vista is helping you. When opening
from a folder, the default is to create a new document. If you right
click on the file instead of double clicking, you will see that the
default (bold) option is "New" rather than "Open". Windows does that
based on the file extension of the document. However, PDF's don't
provide that help. They just Open the file.

If you don't want to use macros, then the only other option I see for
you is to mark all the templates Read-Only.

--
Dawn Crosier
Microsoft MVP
"Education Lasts a Lifetime"
This message is posted to a newsgroup. Please post replies and questions
to the newsgroup so that others can learn as well.




Thanks Dawn,

I plugged in this code, but still didn't get it to work. Also, because so
many people are going to be using this, I don't want to use macros because
many will have them disabled. I'm trying to "dummy-proof" this process.

I don't understand why there is a difference when a template is opened from
a link within a PDF and when it is just opened from a folder. Since the
point of a template is to prevent people from changing the template, why does
it open so the template itself is changed? Is this a bug in Word? Are there
any other options?

Thank you very much!

No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.516 / Virus Database: 269.17.12/1202 - Release Date:
12/29/2007 1:27 PM
 

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