Thanks Nigel. One question - when i go to reopen a previously created
invoice it runs the macro again and duplicates the invoice with a new
number. is there any way to prevent this? Thanks.
On Mar 29, 2:10*am, "Nigel" wrote:
Create your invoice template and enter first invoice # -1 in cell c5, place
the following code into the workbook open event and manually save file as
"Template.xlt". *If you are using Excel 2007 change as required.
Private Sub Workbook_Open()
* *Dim filePath As String
* *filePath = "C:\Users\User\Desktop\Invoices\"
* *With Sheets("Sheet1").Range("C5")
* * *' increment invoice number
* * * .Value = .Value + 1
* * *' save template with next higher number
* * *Application.DisplayAlerts = False
* * *ActiveWorkbook.SaveAs Filename:=filePath & "Template.xlt",
FileFormat:=xlTemplate8
* * *Application.DisplayAlerts = True
* * *' save invoice numbered
* * *ActiveWorkbook.SaveAs Filename:=filePath & "Invoice" & .Value & ".xls",
FileFormat:=xlExcel8
* *End With
End Sub
--
Regards,
Nigel
wrote in message
...
I am creating a template for invoices. I want it to automatically fill
in the invoice number in cell C5 each time I open it, just one number
higher than the last one. I also want it to automatically save to a
folder on my desktop called "Invoices". How can I do this with VB?
Thanks.- Hide quoted text -
- Show quoted text -