![]() |
Date formula in file name
Hi,
I'm looking to see if possible a date is inserted before or after the file name on saving. e.g. Stock as of 25/10/2006 (this as the file name auto updated when the file is saved by the user. Is this possible??? Thanks |
Date formula in file name
Try this:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) ActiveWorkbook.SaveAs Filename:="Stock as of " & Format(Date, "yyyy-mm-dd") & ".xls" End Sub santaviga wrote: Hi, I'm looking to see if possible a date is inserted before or after the file name on saving. e.g. Stock as of 25/10/2006 (this as the file name auto updated when the file is saved by the user. Is this possible??? Thanks |
Date formula in file name
Hi,
I have done this in VB came up with error, OK'd it and now text red, closed VB and tried saving file and not inputting date when looking at the file name Mark " wrote: Try this: Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) ActiveWorkbook.SaveAs Filename:="Stock as of " & Format(Date, "yyyy-mm-dd") & ".xls" End Sub santaviga wrote: Hi, I'm looking to see if possible a date is inserted before or after the file name on saving. e.g. Stock as of 25/10/2006 (this as the file name auto updated when the file is saved by the user. Is this possible??? Thanks |
Date formula in file name
What section is appearing in red? I tested before posting and it
worked fine. santaviga wrote: Hi, I have done this in VB came up with error, OK'd it and now text red, closed VB and tried saving file and not inputting date when looking at the file name Mark " wrote: Try this: Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) ActiveWorkbook.SaveAs Filename:="Stock as of " & Format(Date, "yyyy-mm-dd") & ".xls" End Sub santaviga wrote: Hi, I'm looking to see if possible a date is inserted before or after the file name on saving. e.g. Stock as of 25/10/2006 (this as the file name auto updated when the file is saved by the user. Is this possible??? Thanks |
Date formula in file name
Mark, there is nothing wrong with the code:
ActiveWorkbook.SaveAs Filename:="Stock_ as of " & Format(Date, "yyyy-mm-dd") & ".xls" Just make sure you don't drop any of the quote marks, periods, commas, parentheses or ampesand. " wrote: What section is appearing in red? I tested before posting and it worked fine. santaviga wrote: Hi, I have done this in VB came up with error, OK'd it and now text red, closed VB and tried saving file and not inputting date when looking at the file name Mark " wrote: Try this: Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) ActiveWorkbook.SaveAs Filename:="Stock as of " & Format(Date, "yyyy-mm-dd") & ".xls" End Sub santaviga wrote: Hi, I'm looking to see if possible a date is inserted before or after the file name on saving. e.g. Stock as of 25/10/2006 (this as the file name auto updated when the file is saved by the user. Is this possible??? Thanks |
Date formula in file name
Sorry to be pain but all text is RED except for End Sub, and still not
working, must be doing something wrong do I have to run macro or anything else, when I save the file only returning the name I give it? Mark " wrote: What section is appearing in red? I tested before posting and it worked fine. santaviga wrote: Hi, I have done this in VB came up with error, OK'd it and now text red, closed VB and tried saving file and not inputting date when looking at the file name Mark " wrote: Try this: Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) ActiveWorkbook.SaveAs Filename:="Stock as of " & Format(Date, "yyyy-mm-dd") & ".xls" End Sub santaviga wrote: Hi, I'm looking to see if possible a date is inserted before or after the file name on saving. e.g. Stock as of 25/10/2006 (this as the file name auto updated when the file is saved by the user. Is this possible??? Thanks |
Date formula in file name
No Problem. We'll get it worked out. Are you placing this code in the
workbook module? santaviga wrote: Sorry to be pain but all text is RED except for End Sub, and still not working, must be doing something wrong do I have to run macro or anything else, when I save the file only returning the name I give it? Mark " wrote: What section is appearing in red? I tested before posting and it worked fine. santaviga wrote: Hi, I have done this in VB came up with error, OK'd it and now text red, closed VB and tried saving file and not inputting date when looking at the file name Mark " wrote: Try this: Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) ActiveWorkbook.SaveAs Filename:="Stock as of " & Format(Date, "yyyy-mm-dd") & ".xls" End Sub santaviga wrote: Hi, I'm looking to see if possible a date is inserted before or after the file name on saving. e.g. Stock as of 25/10/2006 (this as the file name auto updated when the file is saved by the user. Is this possible??? Thanks |
Date formula in file name
I am in the workbook and press alt+F11 then double click on workbook and this
brings up a new window " wrote: No Problem. We'll get it worked out. Are you placing this code in the workbook module? santaviga wrote: Sorry to be pain but all text is RED except for End Sub, and still not working, must be doing something wrong do I have to run macro or anything else, when I save the file only returning the name I give it? Mark " wrote: What section is appearing in red? I tested before posting and it worked fine. santaviga wrote: Hi, I have done this in VB came up with error, OK'd it and now text red, closed VB and tried saving file and not inputting date when looking at the file name Mark " wrote: Try this: Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) ActiveWorkbook.SaveAs Filename:="Stock as of " & Format(Date, "yyyy-mm-dd") & ".xls" End Sub santaviga wrote: Hi, I'm looking to see if possible a date is inserted before or after the file name on saving. e.g. Stock as of 25/10/2006 (this as the file name auto updated when the file is saved by the user. Is this possible??? Thanks |
Date formula in file name
|
Date formula in file name
Mark,
I emailed the workbook. However, as I mentioned in my email, the problem was the line breaks in the code you picked up when you copied from the site to your workbook. Alan santaviga wrote: Can you possibly e-mail to me a one that you do so I can look up what you've done, just a test document to or is this not possible? Regards, Mark " wrote: No Problem. We'll get it worked out. Are you placing this code in the workbook module? santaviga wrote: Sorry to be pain but all text is RED except for End Sub, and still not working, must be doing something wrong do I have to run macro or anything else, when I save the file only returning the name I give it? Mark " wrote: What section is appearing in red? I tested before posting and it worked fine. santaviga wrote: Hi, I have done this in VB came up with error, OK'd it and now text red, closed VB and tried saving file and not inputting date when looking at the file name Mark " wrote: Try this: Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) ActiveWorkbook.SaveAs Filename:="Stock as of " & Format(Date, "yyyy-mm-dd") & ".xls" End Sub santaviga wrote: Hi, I'm looking to see if possible a date is inserted before or after the file name on saving. e.g. Stock as of 25/10/2006 (this as the file name auto updated when the file is saved by the user. Is this possible??? Thanks |
Date formula in file name
Thanks a lot Alan, much appreciated for your Help dude.
Just starting out on VBA Thanks again Mark " wrote: Mark, I emailed the workbook. However, as I mentioned in my email, the problem was the line breaks in the code you picked up when you copied from the site to your workbook. Alan santaviga wrote: Can you possibly e-mail to me a one that you do so I can look up what you've done, just a test document to or is this not possible? Regards, Mark " wrote: No Problem. We'll get it worked out. Are you placing this code in the workbook module? santaviga wrote: Sorry to be pain but all text is RED except for End Sub, and still not working, must be doing something wrong do I have to run macro or anything else, when I save the file only returning the name I give it? Mark " wrote: What section is appearing in red? I tested before posting and it worked fine. santaviga wrote: Hi, I have done this in VB came up with error, OK'd it and now text red, closed VB and tried saving file and not inputting date when looking at the file name Mark " wrote: Try this: Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) ActiveWorkbook.SaveAs Filename:="Stock as of " & Format(Date, "yyyy-mm-dd") & ".xls" End Sub santaviga wrote: Hi, I'm looking to see if possible a date is inserted before or after the file name on saving. e.g. Stock as of 25/10/2006 (this as the file name auto updated when the file is saved by the user. Is this possible??? Thanks |
All times are GMT +1. The time now is 07:17 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com