Thanks for your help. It's basically working except for two things. It's
asking if I want to save changes to "new invoice". I would like the blank
invoice, "new invoice" to close automatically without saving changes,
otherwise it won't be blank anymore. Also, it's opening the "customer name
(D13)" file. I would like the new file to save but remain closed. Is there
a way to do this? Also, the last 3 lines of the macro created an error.
Thanks again.
Rich J wrote:
>if you are basically trying to copy the invoice to a new workbook without the
>macros then copy the worksheet to a new workbook and save only the sheet.
>
>Private Sub Workbook_BeforeClose(Cancel As Boolean)
>dim ThisFile, ShName as string
>
>ShName = Activesheet.Name
>Sheets(ShName).Select
> Sheets(ShName).Copy
> ThisFile = Range("D13").Value
>
> ActiveWorkbook.SaveAs Filename:= _
> ThisFile, FileFormat:=xlNormal, _
> Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
> CreateBackup:=False
> ' if you want to change the sheet name to the person's name also or create
>a new name
> Windows(ThisFile).Activate
> ActiveSheet.Name = ThisFile
>End Sub
>
>I didn't try running this from a BeforeClose routine. You may need to create
>a button on your original worksheet and run the routine from there.
>
>> Hello, I'm a beginner at using Excel macros, and after much cursing I was
>> finally able to get two macros to run on the same workbook. The one I'm
>[quoted text clipped - 19 lines]
>> ActiveWorkbook.SaveAs Filename:=ThisFile
>> End Sub
--
Message posted via
http://www.officekb.com