Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Christopher M.
 
Posts: n/a
Default Master invoice number

The following code updates an invoice number in a master invoice file, after
a separate invoice file (e.g. one invoice per customer) has been printed.
Having a master invoice number in a separate file enables multiple users to
print different invoices, while maintaining a chronological invoice number.
The value of this master invoice number can be linked to your Excel
worksheet.

Private Sub Workbook_BeforePrint(Cancel As Boolean)
On Error GoTo ErrorHandler

'cancel printing so we can print in this procedure, then do our own
after print
Cancel = True
'disable events so beforeprint isn't called again
Application.EnableEvents = False

With Sheet1
.PrintOut


' Open the source file
' for local drive
'Workbooks.Open ("C:\Documents and Settings\BaronVS\My
Documents\Weekly new Invoices\master invoice number.xls")
'for a network share
Workbooks.Open ("\\OFFICE1\SharedDocs\master invoice number.xls")


' change value (invoice number) _after_ printing
' instead of changing a cell we change the master invoice number
ActiveWorkbook.Sheets(1).Range("A1").Value =
ActiveWorkbook.Sheets(1).Range("A1").Value + 1

'Close the master invoice file
ActiveWorkbook.Close SaveChanges:=True

' To display the invoice number in your worksheet, link a cell to
the value in the 'master invoice number' file

End With

ErrorHandler:
' want to make sure we re-enable events if there's an error
Application.EnableEvents = True
End Sub


W. Pooh (AKA Winnie P.)
"Don't eat soup! Soup makes you poop!"
--Baron von Stinkipantz III


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
creating an invoice for work Beth Excel Worksheet Functions 4 July 16th 05 09:25 PM
Master Workbook used as my template? tb New Users to Excel 4 March 10th 05 11:42 PM
how do i link a number of worksheets to one master worksheet? Rusty Excel Worksheet Functions 0 January 24th 05 08:49 AM
Random Number Questions Greegan Excel Worksheet Functions 1 January 5th 05 02:00 AM
updating invoice number on excel spreadsheet beave Excel Worksheet Functions 3 December 26th 04 03:01 PM


All times are GMT +1. The time now is 06:31 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"