How do I stop being prompted to save a template

D

DevalilaJohn

I have a template for a document that includes a command button which when
pressed will do a save by assigning a file name based on a text string and
looking up a number from a flat file. As part of the save process, the
number gets incremented.

This all works fine. What doesn't work quite the way I'd like is that when
closing a document created off the template, the user is asked if they want
to save changes to the template as well as the new document. How can I
prevent the prompt on saving changes to the template from appearing?

Thanks for any suggestions.

John
 
D

Doug Robbins - Word MVP

Can't tell you what's causing that to happen without you showing us the code
that you have in the template.

However, take a look at the article "Creating sequentially numbered
documents (such as invoices)" at:

http://www.word.mvps.org/FAQs/MacrosVBA/NumberDocs.htm


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
D

DevalilaJohn

Doug,

Thanks for the reply. As I can have multiple users submitting a form, I
need to put the number somewhere that all can get to it (P: on our system
network is a public drive). Here's the code.
************ Start of Code***********
Private Sub btnSubmit_Click()
Dim intLastNum As Integer
Dim strFileName As String
Dim strNumFile As String

strNumFile = "H:\ProcessImprovement\SerNum.dat"

Open strNumFile For Input As #1 'get the last number used
Input #1, intLastNum
Close #1

intLastNum = intLastNum + 1
SPIR_number = CStr(intLastNum) 'put the number in this form

strFileName = "H:\ProcessImprovement\PIR" & intLastNum & ".Doc" 'file name
ActiveDocument.SaveAs FileName:=strFileName, AddToRecentFiles:=True 'save

Open strNumFile For Output As #1 'update last number used
Write #1, intLastNum
Close #1

MsgBox "Your request has been saved as PIR" & intLastNum, vbOKOnly, "PIR
Processing"
ActiveDocument.Close
End Sub

****** End of Code ***********

Thanks again for your help.

John
 
J

Jezebel

That code isn't causing changes to the template, so something else must be.
You can try pinning it down by checking the value of
Activedocument.AttachedTemplate.saved (which you can simply print in the
immediate window) -- when this value changes to FALSE, something has
modified the template.
 
D

DevalilaJohn

Thanks for the inputs. I put a series of prints in the code stream and all
came back True. So I added a Document_Close event. This also shows True.
Is there another event where I can trap the change?

When I have the code close the document, all closes as I would like, when I
force a close (upper right hand corner X), I get the message.

Thanks again for all the help.

John
 
C

Charles Kenyon

Stop making changes to the template would be one way. I can't guess what
changes you are making, though. These are often interface changes, but it
could be in your case that it is a document variable.
--
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

Jezebel

There are some oddballs that make Word think a template has changed, like
querying the CustomDocumentProperties collection. If you can find the line
of code that's doing it (if it is a line of code), you can set .Saved back
to true on the following line.
 

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