Word97: Prompts to Save Template (.dot) file

V

VBA Coder

I have a Word Template that the users use to create a new Document from. I
have VBA code that adds NEW tables to the Document (.doc NOT .dot file)
depending on what the user enters in a UserForm. For some reason, when the
user closes their Document (.doc), they are being asked whether they want to
save the template (.dot) file. In Word 97 this happens, but in Word 2000,
this does not happen - they are not prompted to save the .dot file.

Anyone know why this is happening?
 
R

RWN

Not an expert, but anytime a similar thing has happened to me it's
usually a corrupted Normal.dot.
Also, you say "users", you should ensure that each user has his/her own
Normal.dot, vs. all users pointing at a common template.

HTH
 
T

Tony Strazzeri

Wortd may be doing some conversion if the dot file was created in one
version of word and opened in another. The conversion process causes
word to think the template has been changed.

You can get around this by setting the save state of the template to
Activedocument.attachedtemplate.saved=true

Hope this helps
Cheers

TonyS.
 
V

VBA Coder

The template was initially created in Word 2000, but when I had to convert
it to a Word 97 template (some users are on Word 97 while others are on Word
2000), I had quite a few VBA changes to make using Word 97 to make it
compatible for Word 97. Once that was complete, I saved it in Word 97.
Shouldn't that have converted it?

BTW...I don't want to put in the ActiveDocument.AttachedTemplate.Saved =
True command because we don't want their template file getting saved. This
template file is solely for the purpose of creating a new Document - plus it
gives another layer of questions for the user when they are prompted to save
their template file, which should not be happening.

Any other thoughts???
 
V

VBA Coder

Thank you for your suggestion on the corrupted Normal.dot, but after
deleting my Normal.dot and any other ones on my PC, I let Word recreate the
Normal.dot file and went ahead and created a new document based on my
template file. However, the same thing happened after a table was inserted
in the document via VBA code within the template (.dot) - I was prompted to
Save my template file (.dot) after I was prompted to save my document
(.doc). Saving the document (.doc) is fine, however, saving the template
(.dot) is not. NOTE: If I don't execute the code that inserts the tables
(there are buttons on the UserForm that allow the user to add additional
tables to the document), I don't get the prompt to save my template (.dot),
I only get the prompt to save my document (.doc), which is what I would
expect when I do insert table(s).

The other thing you noted about making sure each user points to a common
template - the way we have it setup is, each user will copy from the server,
the designated Template (.dot) file that they will use to create their
document. In this case, they will either copy a Word97 version or a Word
2000 version of a template we'll call "MyLetterX_97.dot" or
"MyLetterX_2000.dot", to create their document off of.
 
K

Kemosabe

The template was initially created in Word 2000, but when I had to convert
it to a Word 97 template (some users are on Word 97 while others are on Word
2000), I had quite a few VBA changes to make using Word 97 to make it
compatible for Word 97. Once that was complete, I saved it in Word 97.
Shouldn't that have converted it?

BTW...I don't want to put in the ActiveDocument.AttachedTemplate.Saved =
True command because we don't want their template file getting saved. This
template file is solely for the purpose of creating a new Document - plus it
gives another layer of questions for the user when they are prompted to save
their template file, which should not be happening.

Any other thoughts???

ActiveDocument.AttachedTemplate.Saved =True does not save the
document. It just sets a flag so that the application thinks that it
has been saved since the last changes were made, and therefore it does
not need to be saved. Since Word thinks the template is already
saved, it does not prompt to save the template, neither does it
attempt to save the template.
 
V

VBA Coder

Kemosabe:

Thank you for pointing out to me about how that property works.
HOWEVER...there is one major caveat to this, and that is, if I am testing
with this property set to TRUE, and I make changes to my template, when I
close my template, I lose all my changes, because I was never prompted to
save my template. I just have to remember to comment this out when I am
testing.

This is a start...but am still looking for a better solution.
 
R

RWN

Jon;
I just wanted to correct your interpretation of what I said about the
Normal.Dot.
I said;
Each user should have their *own* copy, not point at a common copy.

This is getting over my head, but I've never had a problem with creating
templates used by multiple users, but perhaps it's a different
environment/application.
FWIW, any time I create a template I place it in the workgroup template
directory of whatever department it's for, make it Read-Only and
Shareable.
The users get it via "New", do their thing and save the created
document. The template is never touched, therefore no message to save
it.
I've never used the AttachedTemplate function, never had to - shows how
much I know:)

When you say that if you make changes to your code with the attached
template = yes, then you have to ensure that you save the template or
you lose all your changes I get a little lost. How are you opening the
template for editing?
i.e. are you bringing it up as a document, making changes and saving it
as a template - if so then you should be opening it as a template.

As I said, I'm not an expert and there's a (good) chance that what
you're doing is beyond me, but thought I'd throw in my two cents worth
(never afraid to show my ignorance!).
 
V

VBA Coder

First, I may have found what is actually causing the message prompt to ask
me to Save my Template. It may be related to creating a PopUp menu bar
on-the-fly, rather than my first thought where I insert Tables into my
document.

Second, yes, if I have that setting to True, and I don't manually save my
template code as I test and make changes, if I exit out, I am not prompted
to save my changes, and all work has been lost.

Third, you asked, "How are you opening the template for editing?" I can do
it one of 2 ways. I can either start Word, then do a File>Open, and open my
..dot file, or, I can create a new document based on my Template (.dot) file
and view the VB code within my .dot file. With this method, you have to
keep 2 things in mind:
1. In my 1st method, where I open my .dot file, I make sure not to run
any of my VB code because if I do, things will get updated in my .dot file
document which is NOT what I want to happen. ie: Bookmarks get updated,
Text get's inserted, Tables get created, etc... And if I save my template
file after I run any VB code the template file will now look like what my
document (.doc) should look like when I would create a document based on my
template.
2. In my 2nd method, where I go and create a new document based on my
template file (.dot), if I have the AttachedTemplate set to True, any code
changes I make will not be saved, unless I manually SAVE the code as I make
changes. In the method, I will be asked to save 2 files, my document (.doc)
and my template (.dot).
 
V

VBA Coder

A new find! Where I first thought the culprit causing the "Save As" dialog
box on my template file was the code to add NEW tables to my document, I
have now discovered it is actually the creation of a PopUp MenuBar that is
causing the "Save As" dialog box. I removed the code
"ActiveDocument.AttachedTemplate.Saved =True" and added new Tables to my
document, and everything was fine - no dialog box to save.

When the Users create a new document based on the Template file, a UserForm
is loaded where they enter in criteria that will populate bookmarks and add
tables and text to the document. On this UserForm I created a "Hide"
button, that allows the user to Hide the Form so that they can switch over
to the document to make changes. Because Word97 makes all UserForms modal,
there was no way to allow the user to work on the document without closing
the UserForm. However, the users need to keep this form loaded so that they
can make additional changes on the UserForm which will in turn update the
document. So the "Hide" button method was created. When the user clicks
the "Hide" button, I created a PopUp menu that has a button on it that
allows them to "Show" the UserForm so that when they've made all their
changes to the document, they can come back to the UserForm.

It is this PopUp Command Bar that is causing Word to think the Template has
changed, therefore, prompting the user to "Save" the template file (.dot)
when they close their Document (.doc). I have made the Command Bar
"Temporary", so that it is not part of the Template. Any ideas why this may
be causing Word to think the Template has changed? Even with the
ActiveDocument.AttachedTemplate.Saved =True, as long as the user clicks on
the btnHide, the user will always get the "Save As" dialog box on the
Template file. My code is below:

Private Sub btnHide_Click()

' Hide the UserForm
frmMacroMain.Hide

' Show the PopUp Form Button to allow the user to Re-Show the form
ShowPopUpFormButton

End Sub




Public Function ShowPopUpFormButton()
Dim myBar As CommandBar
Dim graphBtn As CommandBarButton
Dim bFound As Boolean, sToolBarName As String

sToolBarName = "ShowMacroForm"

' Check if the PopUp Form already exists. If so, just show it, otherwise,
create it
For Each myBar In CommandBars
If Left$(myBar.Name, Len(sToolBarName)) = sToolBarName Then
bFound = True
Exit For
End If
Next

If bFound Then
CommandBars(sToolBarName).Visible = True
Else
Set myBar = CommandBars.Add(Name:=sToolBarName,
Position:=msoBarFloating, _
Temporary:=True)
myBar.Visible = True
Set graphBtn = myBar.Controls.Add(Type:=msoControlButton)
With graphBtn
.Caption = "&Show Form"
.Style = msoButtonCaption
.DescriptionText = "&Show Macro Form"
' When clicked, run the Macro to Show the Form
.OnAction = "ShowMacroForm"
End With
End If

End Function
 

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