ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel VBA - Error handling problem (https://www.excelbanter.com/excel-programming/288533-excel-vba-error-handling-problem.html)

brutalmetal[_2_]

Excel VBA - Error handling problem
 
Hi,

I am using centralized error handling in my VB program whic
manipulates excel sheets.

My question is this:

I have a function which I call whenever a run time error is detected


I open a file in my main code.
The main code calls other subroutines.
When a run time error is detected, the error handling function i
called.
The erro handling function displays an appropraite message and has th
"End" statement.
I expect the end statement to close all files that were opened in th
program. But it turns out that it only closes files opened in th
sub/function where the error occured.

Can anyone please tell me how I make sure all files opened durin
program execution are closed.

Thanks!
BrutalMeta

--
Message posted from http://www.ExcelForum.com


Dave Peterson[_3_]

Excel VBA - Error handling problem
 
Keep track of them and close the ones you want to close????


"brutalmetal <" wrote:

Hi,

I am using centralized error handling in my VB program which
manipulates excel sheets.

My question is this:

I have a function which I call whenever a run time error is detected.

I open a file in my main code.
The main code calls other subroutines.
When a run time error is detected, the error handling function is
called.
The erro handling function displays an appropraite message and has the
"End" statement.
I expect the end statement to close all files that were opened in the
program. But it turns out that it only closes files opened in the
sub/function where the error occured.

Can anyone please tell me how I make sure all files opened during
program execution are closed.

Thanks!
BrutalMetal

---
Message posted from http://www.ExcelForum.com/


--

Dave Peterson


Dave Peterson[_3_]

Excel VBA - Error handling problem
 
Keep track of them and close the ones you want to close????

"brutalmetal <" wrote:

Hi,

I am using centralized error handling in my VB program which
manipulates excel sheets.

My question is this:

I have a function which I call whenever a run time error is detected.

I open a file in my main code.
The main code calls other subroutines.
When a run time error is detected, the error handling function is
called.
The erro handling function displays an appropraite message and has the
"End" statement.
I expect the end statement to close all files that were opened in the
program. But it turns out that it only closes files opened in the
sub/function where the error occured.

Can anyone please tell me how I make sure all files opened during
program execution are closed.

Thanks!
BrutalMetal

---
Message posted from http://www.ExcelForum.com/


--

Dave Peterson



All times are GMT +1. The time now is 01:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com