Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default 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
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
problems copying invoice form but then changing to a different font jbclem Excel Discussion (Misc queries) 3 February 2nd 10 08:22 AM
Help! having problems with macros/coding Derrick Excel Discussion (Misc queries) 0 July 31st 09 02:15 PM
Macros for invoice Heather C[_2_] Excel Worksheet Functions 2 April 25th 08 08:41 PM
problems with macros cjjoo Excel Worksheet Functions 3 September 8th 05 10:00 AM
Macros Problems bee Excel Programming 2 December 31st 03 09:54 PM


All times are GMT +1. The time now is 12:04 PM.

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"