View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Frank Kabel Frank Kabel is offline
external usenet poster
 
Posts: 3,885
Default "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