djelectric
11-12-2016, 01:26 PM
Hi everyone. I am new to the forum and am hoping someone can help me!
I'm a self employed electrician and im trying to set up an invoicing system.
I am using MS Word 2016 Pro Plus on Windows 10 Pro.
I need my invoice templates to automatically generate a new sequential invoice number in both the filename and the document itself, every time i SAVE an invoice. At the moment i have a macro in place that will do this but automatically saves a copy of the invoice even if i decide not to type one out, or cancel one and start again. The way it is set up now it will save empty copies of my invoice template and therefore uses up an invoice number.
I just want it to act like a normal template that asks where you want to save it when you click save, but still have the auto numbering...
Also, in addition to the numbering i'd like the filename to also include the client's address that i input into the document when typing my invoices out.. currently i am just copying and pasting it into my filename which is time consuming.
this is the one and only macro i have running at the moment:
Sub AutoNew()
Order = System.PrivateProfileString("D:\Danny\Documents\Custom Office Templates\Invoice-Number.txt", _
"MacroSettings", "Order")
If Order = "" Then
Order = 1
Else
Order = Order + 1
End If
System.PrivateProfileString("D:\Danny\Documents\Custom Office Templates\Invoice-Number.txt", "MacroSettings", _
"Order") = Order
ActiveDocument.Bookmarks("Order").Range.InsertBefore Format(Order, "1600#")
ActiveDocument.SaveAs FileName:="INV" & Format(Order, "1600#")
End Sub
So ideally, the end resulting filename i would like would look like this: INV16027 - 22 Macro Street, London SE1 2AB (address to be sourced from the address field within the document/template)
I hope this makes sense and any help would be HUGELY APPRECIATED!!!! I am a complete newcomer to macros and am struggling big time!
Many thanks!
Danny.
I'm a self employed electrician and im trying to set up an invoicing system.
I am using MS Word 2016 Pro Plus on Windows 10 Pro.
I need my invoice templates to automatically generate a new sequential invoice number in both the filename and the document itself, every time i SAVE an invoice. At the moment i have a macro in place that will do this but automatically saves a copy of the invoice even if i decide not to type one out, or cancel one and start again. The way it is set up now it will save empty copies of my invoice template and therefore uses up an invoice number.
I just want it to act like a normal template that asks where you want to save it when you click save, but still have the auto numbering...
Also, in addition to the numbering i'd like the filename to also include the client's address that i input into the document when typing my invoices out.. currently i am just copying and pasting it into my filename which is time consuming.
this is the one and only macro i have running at the moment:
Sub AutoNew()
Order = System.PrivateProfileString("D:\Danny\Documents\Custom Office Templates\Invoice-Number.txt", _
"MacroSettings", "Order")
If Order = "" Then
Order = 1
Else
Order = Order + 1
End If
System.PrivateProfileString("D:\Danny\Documents\Custom Office Templates\Invoice-Number.txt", "MacroSettings", _
"Order") = Order
ActiveDocument.Bookmarks("Order").Range.InsertBefore Format(Order, "1600#")
ActiveDocument.SaveAs FileName:="INV" & Format(Order, "1600#")
End Sub
So ideally, the end resulting filename i would like would look like this: INV16027 - 22 Macro Street, London SE1 2AB (address to be sourced from the address field within the document/template)
I hope this makes sense and any help would be HUGELY APPRECIATED!!!! I am a complete newcomer to macros and am struggling big time!
Many thanks!
Danny.