Hi there,
I have got a macro attached to a template so that whenever the template is
opened it automatically opens and saves under a new sequentual number but,
the document also saves as a template and when I go in to the new saved
document it runs the macro again.
The macro is:
Sub AutoOpen()
Order = System.PrivateProfileString("C:\Documents and Settings\acollin\My
Documents\Order Folder\Settings.Txt", "MacroSettings", "Order")
If Order = "" Then
Order = 406751
Else
Order = Order + 1
End If
System.PrivateProfileString("C:\Documents and Settings\acollin\My
Documents\Order Folder\Settings.Txt", "MacroSettings", "Order") = Order
ActiveDocument.Bookmarks("order").Range.InsertBefore Format(Order, "#")
ActiveDocument.SaveAs FileName:="C:\Documents and Settings\acollin\My
Documents\Order Folder\Order Number -" & Format(Order, " #")
End Sub
How can I stop the document that it create from being a template? Hopefully
this will then stop the macro from running when opening.
Any help on this will be greatly appreciated.
many thanks
Russ - 20 Jul 2007 11:14 GMT
Make sure that you are not opening a .dot file directly, otherwise you will
be asked to save changes, if changed while open.
I don't see anything in the code below that is directly altering a .dot
file.
See this website for tips on how to use templates.
<http://www.shaunakelly.com/word/templaterelations/index.html>
Also, templates are not the same as Documents with formfields.
I've got a suspicion that you're talking about on-line forms which should be
set up and saved as templates. Then a new document based on the template is
opened and filled out. You don't open the template or .dot file.
> Hi there,
>
[quoted text clipped - 30 lines]
>
> many thanks

Signature
Russ
drsmN0SPAMikleAThotmailD0Tcom.INVALID
David Sisson - 20 Jul 2007 13:56 GMT
Russ is right.
How do you get a new Document started? Do you File --> New, or File -->
Open. If it's the latter, then that's your problem.
File --> New creates a document BASED ON the template, but the autorun code
doesn't move with it, so when you open the document later on, there shouldn't
be a new document number generated.