Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default "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



  #2   Report Post  
Posted to microsoft.public.excel.programming
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




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default "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






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default "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







Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I prevent Excel 2007 from leaving ".tmp" files in my folder Deb M Excel Discussion (Misc queries) 5 June 4th 09 07:16 PM
formula error- ("Nesting more than 7 functions"- Feb4) Brian Excel Worksheet Functions 3 February 5th 09 11:33 PM
Excel "Move or Copy" and "Delete" sheet functions dsiama Excel Worksheet Functions 1 December 28th 07 01:57 PM
HELP on "left","right","find","len","substitute" functions serene83 Excel Discussion (Misc queries) 5 June 27th 06 02:23 AM
can we convert "2 days 16 hrs" to " 64hrs" using excel functions chris Excel Worksheet Functions 5 April 24th 06 12:53 AM


All times are GMT +1. The time now is 11:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"