![]() |
"Restore" excel functions when error or leaving?
Hi all,
This is about if users get an error in the middle of my code or just leave a sheet for a while to go to a completly other xls-file of they own. Is here a nice way of restore the usual behavour of excel ?? Example: I use "Application.EnableEvent = False" in several Subs of code, but use to have a "Application.EnableEvent = True" in the end of the Sub. The same with a OnKey-code to stop Paste functions. In one Sub I update the sheet/cell formats through copy from a template sheet and SpecialPaste Formats only. Now I discovered in an totally new xls-file, that THAT Sheet took the template formats ... [ Actually, the last behavour shouldn't be able to happen...i have a worksheet_change event to trigg the formatUpdate and the new sheet ( I coudn't say it's a xls file, it wasn't saved as one yet, if this matters...) took the template format when I pasted into a cell !!!! ] Therefore - can I ensure to keep the code into the specific file I've created or it's children... /Regards |
"Restore" excel functions when error or leaving?
Hi
try something like sub foo() on error goto errhandler 'your code errhandler: application.enableevents=true end sub -- Regards Frank Kabel Frankfurt, Germany "Imbecill" schrieb im Newsbeitrag ... Hi all, This is about if users get an error in the middle of my code or just leave a sheet for a while to go to a completly other xls-file of they own. Is here a nice way of restore the usual behavour of excel ?? Example: I use "Application.EnableEvent = False" in several Subs of code, but use to have a "Application.EnableEvent = True" in the end of the Sub. The same with a OnKey-code to stop Paste functions. In one Sub I update the sheet/cell formats through copy from a template sheet and SpecialPaste Formats only. Now I discovered in an totally new xls-file, that THAT Sheet took the template formats ... [ Actually, the last behavour shouldn't be able to happen...i have a worksheet_change event to trigg the formatUpdate and the new sheet ( I coudn't say it's a xls file, it wasn't saved as one yet, if this matters...) took the template format when I pasted into a cell !!!! ] Therefore - can I ensure to keep the code into the specific file I've created or it's children... /Regards |
"Restore" excel functions when error or leaving?
Thank a lot to your respons - yes, error handling and to carefully write the
code to take the original values after each sub... But if I miss something there would be nice to have something to unable an OnKey value etc. to continue outside my xls file. Is there nothing I can put in a Workbook_deactivate event or something? /Regards "Frank Kabel" skrev i meddelandet ... Hi try something like sub foo() on error goto errhandler 'your code errhandler: application.enableevents=true end sub -- Regards Frank Kabel Frankfurt, Germany "Imbecill" schrieb im Newsbeitrag ... Hi all, This is about if users get an error in the middle of my code or just leave a sheet for a while to go to a completly other xls-file of they own. Is here a nice way of restore the usual behavour of excel ?? Example: I use "Application.EnableEvent = False" in several Subs of code, but use to have a "Application.EnableEvent = True" in the end of the Sub. The same with a OnKey-code to stop Paste functions. In one Sub I update the sheet/cell formats through copy from a template sheet and SpecialPaste Formats only. Now I discovered in an totally new xls-file, that THAT Sheet took the template formats ... [ Actually, the last behavour shouldn't be able to happen...i have a worksheet_change event to trigg the formatUpdate and the new sheet ( I coudn't say it's a xls file, it wasn't saved as one yet, if this matters...) took the template format when I pasted into a cell !!!! ] Therefore - can I ensure to keep the code into the specific file I've created or it's children... /Regards |
"Restore" excel functions when error or leaving?
Hi
IMHO good programming practice should ensure this for each procedure and not on a higher level -- Regards Frank Kabel Frankfurt, Germany "Imbecill" schrieb im Newsbeitrag ... Thank a lot to your respons - yes, error handling and to carefully write the code to take the original values after each sub... But if I miss something there would be nice to have something to unable an OnKey value etc. to continue outside my xls file. Is there nothing I can put in a Workbook_deactivate event or something? /Regards "Frank Kabel" skrev i meddelandet ... Hi try something like sub foo() on error goto errhandler 'your code errhandler: application.enableevents=true end sub -- Regards Frank Kabel Frankfurt, Germany "Imbecill" schrieb im Newsbeitrag ... Hi all, This is about if users get an error in the middle of my code or just leave a sheet for a while to go to a completly other xls-file of they own. Is here a nice way of restore the usual behavour of excel ?? Example: I use "Application.EnableEvent = False" in several Subs of code, but use to have a "Application.EnableEvent = True" in the end of the Sub. The same with a OnKey-code to stop Paste functions. In one Sub I update the sheet/cell formats through copy from a template sheet and SpecialPaste Formats only. Now I discovered in an totally new xls-file, that THAT Sheet took the template formats ... [ Actually, the last behavour shouldn't be able to happen...i have a worksheet_change event to trigg the formatUpdate and the new sheet ( I coudn't say it's a xls file, it wasn't saved as one yet, if this matters...) took the template format when I pasted into a cell !!!! ] Therefore - can I ensure to keep the code into the specific file I've created or it's children... /Regards |
All times are GMT +1. The time now is 10:18 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com