Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
noob: problems with macros in invoice
the posting rules said to be very specific when posting so i'll try t
be as descriptive as possible. i'm working on an invoice for a friend' business and i'd like to add a lot of automation to the file. i go pretty much everything working but i'm stumped on a couple of issues this is what it does right. 1. the invoice number is set to increase each time the invoice templat is opened (programmed in the macro). 2. the current date is automatically displayed in the date box when th template is opened 3. when the user clicks 'save' or 'save as', it is either saved as th invoice number, or the invoice number is the default filename in th save as box, respectively. the problem is this... everytime the user opens one of the previou invoices, the macros continue to do their work. that means that whe invoice #102 is opened, it automatically increases the invoice number i managed to get the date to stay frozen when opening old invoices s the problem is half solved. here is my macro. Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel A Boolean) Application.DisplayAlerts = False ThisWorkbook.SaveAs ThisWorkbook.Path & "\" & _ ThisWorkbook.Worksheets("Sheet1").Range("g14").Val ue & _ ".xls" Application.DisplayAlerts = True Set datehalter = Sheets("Sheet1").Range("g12") With datehalter .Value = Sheets("Sheet1").Range("g12") End With Set deincrement = Sheets("Sheet1").Range("F14") With deincrement .Value = 1 End With End Sub Sub Workbook_Open() Set ponum = Sheets("Sheet1").Range("g14") With ponum .Value = .Value + 2 End With ActiveWorkbook.Save End Sub to clarify any confusion, this is what's in the following cells. g12 = date f14 = "0" (my effort to solve the prob) g14 = invoice number i believe that the problem might be solved if i could find a command t enable certain macros if the filename is numberic, and other macros i the filename is text. any help would be greatly appreciated -- Message posted from http://www.ExcelForum.com |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
problems with macros in invoice
What is guaranteed to be different between your template and an invoice.
Check that before you increment the invoice number or run any code that is unique to when the invoice is initiated. -- Regards, Tom Ogilvy "dogfeet " wrote in message ... the posting rules said to be very specific when posting so i'll try to be as descriptive as possible. i'm working on an invoice for a friend's business and i'd like to add a lot of automation to the file. i got pretty much everything working but i'm stumped on a couple of issues. this is what it does right. 1. the invoice number is set to increase each time the invoice template is opened (programmed in the macro). 2. the current date is automatically displayed in the date box when the template is opened 3. when the user clicks 'save' or 'save as', it is either saved as the invoice number, or the invoice number is the default filename in the save as box, respectively. the problem is this... everytime the user opens one of the previous invoices, the macros continue to do their work. that means that when invoice #102 is opened, it automatically increases the invoice number. i managed to get the date to stay frozen when opening old invoices so the problem is half solved. here is my macro. Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Application.DisplayAlerts = False ThisWorkbook.SaveAs ThisWorkbook.Path & "\" & _ ThisWorkbook.Worksheets("Sheet1").Range("g14").Val ue & _ ".xls" Application.DisplayAlerts = True Set datehalter = Sheets("Sheet1").Range("g12") With datehalter Value = Sheets("Sheet1").Range("g12") End With Set deincrement = Sheets("Sheet1").Range("F14") With deincrement Value = 1 End With End Sub Sub Workbook_Open() Set ponum = Sheets("Sheet1").Range("g14") With ponum Value = .Value + 2 End With ActiveWorkbook.Save End Sub to clarify any confusion, this is what's in the following cells. g12 = date f14 = "0" (my effort to solve the prob) g14 = invoice number i believe that the problem might be solved if i could find a command to enable certain macros if the filename is numberic, and other macros if the filename is text. any help would be greatly appreciated. --- Message posted from http://www.ExcelForum.com/ |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
noob: problems with macros in invoice
Maybe you could just check to see if the name matches the "master" workbook.
if lcase(thisworkbook.name) < "master.xls" then exit sub (at the top of each procedure that shouldn't run) If the folder is in the same location for all users, then you could be more specific. if lcase(thisworkbook.fullname) < "c:\my documents\excel\master.xls" then exit sub end if "dogfeet <" wrote: the posting rules said to be very specific when posting so i'll try to be as descriptive as possible. i'm working on an invoice for a friend's business and i'd like to add a lot of automation to the file. i got pretty much everything working but i'm stumped on a couple of issues. this is what it does right. 1. the invoice number is set to increase each time the invoice template is opened (programmed in the macro). 2. the current date is automatically displayed in the date box when the template is opened 3. when the user clicks 'save' or 'save as', it is either saved as the invoice number, or the invoice number is the default filename in the save as box, respectively. the problem is this... everytime the user opens one of the previous invoices, the macros continue to do their work. that means that when invoice #102 is opened, it automatically increases the invoice number. i managed to get the date to stay frozen when opening old invoices so the problem is half solved. here is my macro. Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Application.DisplayAlerts = False ThisWorkbook.SaveAs ThisWorkbook.Path & "\" & _ ThisWorkbook.Worksheets("Sheet1").Range("g14").Val ue & _ ".xls" Application.DisplayAlerts = True Set datehalter = Sheets("Sheet1").Range("g12") With datehalter Value = Sheets("Sheet1").Range("g12") End With Set deincrement = Sheets("Sheet1").Range("F14") With deincrement Value = 1 End With End Sub Sub Workbook_Open() Set ponum = Sheets("Sheet1").Range("g14") With ponum Value = .Value + 2 End With ActiveWorkbook.Save End Sub to clarify any confusion, this is what's in the following cells. g12 = date f14 = "0" (my effort to solve the prob) g14 = invoice number i believe that the problem might be solved if i could find a command to enable certain macros if the filename is numberic, and other macros if the filename is text. any help would be greatly appreciated. --- Message posted from http://www.ExcelForum.com/ -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
problems copying invoice form but then changing to a different font | Excel Discussion (Misc queries) | |||
Help! having problems with macros/coding | Excel Discussion (Misc queries) | |||
Macros for invoice | Excel Worksheet Functions | |||
problems with macros | Excel Worksheet Functions | |||
Macros Problems | Excel Programming |