Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 100
Default Help needed with Error Handling

I'm new to Error Handling.

I have a macro that is on a loop controlling two workbooks. On most days
everything works fine and there are no issues. Once in a while a worksheet
disappears for no reason. I solved that problem by adding code that closes
and re-opens the offending worksheet on each interation. Now once in even
less of a while, it hangs on re-opening that workbook. I guess it never fully
closed before it was told to re-open, but I'm not sure.

So, I'd like to insert an "on error" code that closes both workbooks and
then fires the marco that starts my loop over again, "Loop" is the name of
that macro. Can anyone help me?

Thanks,
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Help needed with Error Handling

You could probably cure the problem by putting a delay in the existing code
that allows enough time for the offending workbook to do its thing. Here is
a function that you can adjust by changing the value of s. It is measured in
seconds and will respond to tenths of seconds as it is now set at 5/10 or
half a second. To call the function, simply type HalfSecDly at the
appropriate point in your code.

Public Function HalfSecDly()
s = Timer + 0.5
Do While Timer < s
DoEvents
Loop
End Function

"sb1920alk" wrote:

I'm new to Error Handling.

I have a macro that is on a loop controlling two workbooks. On most days
everything works fine and there are no issues. Once in a while a worksheet
disappears for no reason. I solved that problem by adding code that closes
and re-opens the offending worksheet on each interation. Now once in even
less of a while, it hangs on re-opening that workbook. I guess it never fully
closed before it was told to re-open, but I'm not sure.

So, I'd like to insert an "on error" code that closes both workbooks and
then fires the marco that starts my loop over again, "Loop" is the name of
that macro. Can anyone help me?

Thanks,

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 100
Default Help needed with Error Handling

Well, that's not going to solve the underlying problem. This could work if
the time delay is sufficient, but it only takes one hiccup to stop the loop
until I notice it and fix it manually. All I need to do to fix it is close
both files (well...someone one of them is already closed, so I would first
need the error handler to check if each is open and then close it) and then
reopen both files and call my "Loop" macro. This should work every time.

"JLGWhiz" wrote:

You could probably cure the problem by putting a delay in the existing code
that allows enough time for the offending workbook to do its thing. Here is
a function that you can adjust by changing the value of s. It is measured in
seconds and will respond to tenths of seconds as it is now set at 5/10 or
half a second. To call the function, simply type HalfSecDly at the
appropriate point in your code.

Public Function HalfSecDly()
s = Timer + 0.5
Do While Timer < s
DoEvents
Loop
End Function

"sb1920alk" wrote:

I'm new to Error Handling.

I have a macro that is on a loop controlling two workbooks. On most days
everything works fine and there are no issues. Once in a while a worksheet
disappears for no reason. I solved that problem by adding code that closes
and re-opens the offending worksheet on each interation. Now once in even
less of a while, it hangs on re-opening that workbook. I guess it never fully
closed before it was told to re-open, but I'm not sure.

So, I'd like to insert an "on error" code that closes both workbooks and
then fires the marco that starts my loop over again, "Loop" is the name of
that macro. Can anyone help me?

Thanks,

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
Error Handling Kevin Excel Discussion (Misc queries) 4 June 19th 08 12:31 AM
Worksheet-specific event handling needed syswizard Excel Programming 4 March 10th 07 08:53 PM
Error Handling - On Error GoTo doesn't trap error successfully David Excel Programming 9 February 16th 06 05:59 PM
Error Handling Billy Boone Excel Programming 1 July 1st 05 02:21 PM
Error handling with a handling routine ben Excel Programming 0 March 15th 05 03:01 PM


All times are GMT +1. The time now is 12:29 PM.

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

About Us

"It's about Microsoft Excel"