Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Ok I had posted a question about some code (Subject: Code issue -
before_save() - Filename with date stamp - worksheet), to which I got it to work but now it is causing my Excel to completely crash. Any ideas??? Also Why do I get 2 vbok pop up boxes???? Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) MsgBox "You should see something renamed!!", vbOK Sheet1.Name = "As of " & Format(Now(), "MM-DD-YYYY") ChDir "<new dir path" ActiveWorkbook.SaveAs _ "<MyFileName" & Format(Now(), "yyyymmdd") End Sub |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Your save as is calling a save which is going to be an issue. You need to
cancel the pending save make your changes disable events, save the book and then re enable... something like this... Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) On error goto ErrorHandler Application.enableevents = false cancel = true MsgBox "You should see something renamed!!", vbOK Sheet1.Name = "As of " & Format(Now(), "MM-DD-YYYY") ChDir "<new dir path" ActiveWorkbook.SaveAs _ "<MyFileName" & Format(Now(), "yyyymmdd") ErrorHandler: Application.enableevents = true End Sub -- HTH... Jim Thomlinson "awrex" wrote: Ok I had posted a question about some code (Subject: Code issue - before_save() - Filename with date stamp - worksheet), to which I got it to work but now it is causing my Excel to completely crash. Any ideas??? Also Why do I get 2 vbok pop up boxes???? Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) MsgBox "You should see something renamed!!", vbOK Sheet1.Name = "As of " & Format(Now(), "MM-DD-YYYY") ChDir "<new dir path" ActiveWorkbook.SaveAs _ "<MyFileName" & Format(Now(), "yyyymmdd") End Sub |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
THANK YOU!!!!!
Works great. Would you happen to know of web reference that I can look at regarding this. "Jim Thomlinson" wrote: Your save as is calling a save which is going to be an issue. You need to cancel the pending save make your changes disable events, save the book and then re enable... something like this... Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) On error goto ErrorHandler Application.enableevents = false cancel = true MsgBox "You should see something renamed!!", vbOK Sheet1.Name = "As of " & Format(Now(), "MM-DD-YYYY") ChDir "<new dir path" ActiveWorkbook.SaveAs _ "<MyFileName" & Format(Now(), "yyyymmdd") ErrorHandler: Application.enableevents = true End Sub -- HTH... Jim Thomlinson "awrex" wrote: Ok I had posted a question about some code (Subject: Code issue - before_save() - Filename with date stamp - worksheet), to which I got it to work but now it is causing my Excel to completely crash. Any ideas??? Also Why do I get 2 vbok pop up boxes???? Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) MsgBox "You should see something renamed!!", vbOK Sheet1.Name = "As of " & Format(Now(), "MM-DD-YYYY") ChDir "<new dir path" ActiveWorkbook.SaveAs _ "<MyFileName" & Format(Now(), "yyyymmdd") End Sub |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Check out Chip's site. He covers events along with every other VBA ting under
the sun... http://www.cpearson.com/excel/topic.htm -- HTH... Jim Thomlinson "awrex" wrote: THANK YOU!!!!! Works great. Would you happen to know of web reference that I can look at regarding this. "Jim Thomlinson" wrote: Your save as is calling a save which is going to be an issue. You need to cancel the pending save make your changes disable events, save the book and then re enable... something like this... Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) On error goto ErrorHandler Application.enableevents = false cancel = true MsgBox "You should see something renamed!!", vbOK Sheet1.Name = "As of " & Format(Now(), "MM-DD-YYYY") ChDir "<new dir path" ActiveWorkbook.SaveAs _ "<MyFileName" & Format(Now(), "yyyymmdd") ErrorHandler: Application.enableevents = true End Sub -- HTH... Jim Thomlinson "awrex" wrote: Ok I had posted a question about some code (Subject: Code issue - before_save() - Filename with date stamp - worksheet), to which I got it to work but now it is causing my Excel to completely crash. Any ideas??? Also Why do I get 2 vbok pop up boxes???? Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) MsgBox "You should see something renamed!!", vbOK Sheet1.Name = "As of " & Format(Now(), "MM-DD-YYYY") ChDir "<new dir path" ActiveWorkbook.SaveAs _ "<MyFileName" & Format(Now(), "yyyymmdd") End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
BeforeSave event fired but not working when triggered by SaveAs. | Excel Programming | |||
Event (BeforeSave) - How to test VBA code? Dave P. can you hear me now? | Excel Discussion (Misc queries) | |||
CREATING E-MAIL ATTACHMENT WITH 'BeforeSave Events' IN CODE | Excel Programming | |||
Creating TWO-WAY E-Mail Attachments with 'BeforeSave Events' in Code for 2nd E-Mail | Excel Programming | |||
Code Problem in BeforeSave Event | Excel Programming |