utterly confused
New Member
- Joined
- Nov 23, 2005
- Messages
- 28
Help please........have had some help from this site already but stuck again.
I am trying to design an invoice template that will auto number each time it is opened, ie; count by one each time and then auto save and close to a particular file. I therefore need the template to stay as a template and the completed invoice to save to a file path.
I have the following codes in at the minute, the saving part of it seems to be working at the moment, that may change!) it's just the numbering that is not working.
Private Sub Workbook_Open()
Sheets("Sheet1").Select
Sheets("Sheet1").Unprotect
Range("H13").Value = Range("IV1").Value + 1
Sheets("Sheet1").Protect
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim fpath As String, fName As String
fpath = "P:\K.B\GB Galvanising orders\"
fName = Sheets("Sheet1").[B13].Value & " - " & _
Sheets("Sheet1").[H14].Text & " - " & _
Sheets("Sheet1").[H13].Value & ".xls"
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:=fpath & fName
Application.DisplayAlerts = True
End Sub
Please help!! With thanks
I am trying to design an invoice template that will auto number each time it is opened, ie; count by one each time and then auto save and close to a particular file. I therefore need the template to stay as a template and the completed invoice to save to a file path.
I have the following codes in at the minute, the saving part of it seems to be working at the moment, that may change!) it's just the numbering that is not working.
Private Sub Workbook_Open()
Sheets("Sheet1").Select
Sheets("Sheet1").Unprotect
Range("H13").Value = Range("IV1").Value + 1
Sheets("Sheet1").Protect
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim fpath As String, fName As String
fpath = "P:\K.B\GB Galvanising orders\"
fName = Sheets("Sheet1").[B13].Value & " - " & _
Sheets("Sheet1").[H14].Text & " - " & _
Sheets("Sheet1").[H13].Value & ".xls"
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:=fpath & fName
Application.DisplayAlerts = True
End Sub
Please help!! With thanks