S
stuck4once
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
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