Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Error Handling
I have a problem with the following subroutine. The files that it opens are located in one of two locations, and it accomplishes this regardless of what folder the file is located in. The problem is that it pauses execution everytime any line in that particular subroutine gets run. What's more confusing is that before, it worked perfectly, and seemingly without any changes, suddenly this bug cropped up. Sub OpenMatFile(FileName As String) On Error Resume Next Workbooks.Open MatPath & FileName, UpdateLinks:=False, ReadOnly:=True If Err.Number < 0 Then Workbooks.Open MatPath & "2009 Material Archives\" & FileName, UpdateLinks:=False, ReadOnly:=True End If End Sub -- Burnnie Holliday |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Error Handling
What do you mean by "pause", Burnnie? Does it run reeaaallly sloooowwwly, like one or two seconds for each statement (and how do you know?)? Or do you mean it stops after every statement and asks you to hit a button to proceed (and if so how does it do that and what button do you hit)? Or what? Oh, and what do you mean by "seemingly without any changes"? Do you mean that there were changes but they were really really minor (and if so, what were they)? Or do you mean you don't know of any changes at all but there must have been a change because now it acts differently? Or what? --- "Burnnie Holliday" wrote: I have a problem with the following subroutine. The files that it opens are located in one of two locations, and it accomplishes this regardless of what folder the file is located in. The problem is that it pauses execution everytime any line in that particular subroutine gets run. What's more confusing is that before, it worked perfectly, and seemingly without any changes, suddenly this bug cropped up. Sub OpenMatFile(FileName As String) On Error Resume Next Workbooks.Open MatPath & FileName, UpdateLinks:=False, ReadOnly:=True If Err.Number < 0 Then Workbooks.Open MatPath & "2009 Material Archives\" & FileName, UpdateLinks:=False, ReadOnly:=True End If End Sub |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Error Handling
I mean that a dialogue box will appear as if I've pressed Ctrl+Break, giving me the option to continue, end, or debug. If I choose to debug, I can see that the code has stopped immediately after the successful execution of the command. And by without any changes, I mean that I have been working on a different part of the same module, without altering the portion of code that calls the subroutine in question. The behavior seems to have disappeared now, though. I have no idea what it was. However, I don't need this to sneak up on me during a presentation. Do you see any errors with the subroutine at all? -- Burnnie Holliday Data Wrangler "Bob Bridges" wrote: What do you mean by "pause", Burnnie? Does it run reeaaallly sloooowwwly, like one or two seconds for each statement (and how do you know?)? Or do you mean it stops after every statement and asks you to hit a button to proceed (and if so how does it do that and what button do you hit)? Or what? Oh, and what do you mean by "seemingly without any changes"? Do you mean that there were changes but they were really really minor (and if so, what were they)? Or do you mean you don't know of any changes at all but there must have been a change because now it acts differently? Or what? --- "Burnnie Holliday" wrote: I have a problem with the following subroutine. The files that it opens are located in one of two locations, and it accomplishes this regardless of what folder the file is located in. The problem is that it pauses execution everytime any line in that particular subroutine gets run. What's more confusing is that before, it worked perfectly, and seemingly without any changes, suddenly this bug cropped up. Sub OpenMatFile(FileName As String) On Error Resume Next Workbooks.Open MatPath & FileName, UpdateLinks:=False, ReadOnly:=True If Err.Number < 0 Then Workbooks.Open MatPath & "2009 Material Archives\" & FileName, UpdateLinks:=False, ReadOnly:=True End If End Sub |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Error Handling
Whenever I get that dialogue box you speak of, there's an error message in it. It says things like "object is required" or "the last action was canceled by user" or "this method not supported by object", that sort of thing. You sound reasonably experienced, though, and you wouldn't have told me an error message pops up without bothering to read the error message. Tell me you wouldn't have, please. But then, if there's no error message then you would have seen a completely blank box with just the three buttons on it; and I've never seen one of those. Neither have you, perhaps, and you would have mentioned it as surpassingly unusual - but you didn't. So I don't know what to think now. What does the dialogue box SAY? As for the program...well, I suppose MapPath can be counted on to end in a backslash, right? If MatPath is set by logic rather than being a constant, and if that logic is capable of omitting the final "\" unexpectedly, it could result in an intermittent error. But in that case you would've seen an ERROR MESSAGE, which you don't mention and therefore could not have happened, right? |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Error Handling
No, it isn't any sort of error message. All it would say was that code has been terminated (sorry, I don't know why I've been omitting that), which isn't much information at all of why it was terminated, or otherwise I could bugfix that rather easily. I've given the full code some extensive runs now, though, and the error hasn't managed to duplicate itself. That alone should set me at ease since as it stands now, that particular peice of code gets executed twice during the macro, and an almost identical subroutine opens files 22 times. I've given our network quite the workout beta testing this thing. Yes, MatPath is a string constant ending in "\" defined during the module declarations. As long as it isn't a glaring error, then I will chalk it up to a random occurence, that I must have caused some sort of variable confusion somehow that made Excel to force a stop in execution due to an error that was masked by the error handling. That's my best guess, anyways. I was hoping somebody with a bit more experience might have a better clue. -- Burnnie Holliday Data Wrangler "Bob Bridges" wrote: Whenever I get that dialogue box you speak of, there's an error message in it. It says things like "object is required" or "the last action was canceled by user" or "this method not supported by object", that sort of thing. You sound reasonably experienced, though, and you wouldn't have told me an error message pops up without bothering to read the error message. Tell me you wouldn't have, please. But then, if there's no error message then you would have seen a completely blank box with just the three buttons on it; and I've never seen one of those. Neither have you, perhaps, and you would have mentioned it as surpassingly unusual - but you didn't. So I don't know what to think now. What does the dialogue box SAY? As for the program...well, I suppose MapPath can be counted on to end in a backslash, right? If MatPath is set by logic rather than being a constant, and if that logic is capable of omitting the final "\" unexpectedly, it could result in an intermittent error. But in that case you would've seen an ERROR MESSAGE, which you don't mention and therefore could not have happened, right? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
First Error works but Subsequent Error Handling Does Not | Excel Programming | |||
Error handling error # 1004 Run-time error | Excel Programming | |||
Set Error handling INSIDE error-trap | Excel Programming | |||
Error Handling - On Error GoTo doesn't trap error successfully | Excel Programming | |||
Error handling with a handling routine | Excel Programming |