ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Workbook reopens after close (https://www.excelbanter.com/excel-programming/379366-workbook-reopens-after-close.html)

John Michl

Workbook reopens after close
 
I have a some code that uses GetOpenFilename to create an array of
filenames. Then one by one, the file is opened and a range is copied
to the orginal master file. After the copy procedure, the file is
closed and the next one is opened. This procedure seems to work ok but
after it completes, all of of the files seem to open up again.

Note the secondary files are copies of the master file that have been
sent to others for data collection. Therefore, they contain the same
VBA code as the master file. I have a feeling that the presense of
identical VBA code in these files may be causing the problem. Any
chance the macro is getting confused and picking up execution in one of
the other files?

Here's a simplified version of my code. When I run it, I check the
task bar at the MsgBox and have confirmed the secondary files are no
longer loaded. Immediately after clicking ok, those files are
reopened.

Help.

- John


[email protected]

Workbook reopens after close
 
John,
did you forget to post your code?
Catherine


John Michl

Workbook reopens after close
 
Yes, I forgot to post my code but I just figured out the problem. I
had a Workbook_Open event running that included a timer for a short
delay. I added disabled events before opening the files and then
enabled events after closing the files and all works again.

Thanks for looking.

- John

On Dec 13, 4:17 pm, "John Michl" wrote:
I have a some code that uses GetOpenFilename to create an array of
filenames. Then one by one, the file is opened and a range is copied
to the orginal master file. After the copy procedure, the file is
closed and the next one is opened. This procedure seems to work ok but
after it completes, all of of the files seem to open up again.

Note the secondary files are copies of the master file that have been
sent to others for data collection. Therefore, they contain the same
VBA code as the master file. I have a feeling that the presense of
identical VBA code in these files may be causing the problem. Any
chance the macro is getting confused and picking up execution in one of
the other files?

Here's a simplified version of my code. When I run it, I check the
task bar at the MsgBox and have confirmed the secondary files are no
longer loaded. Immediately after clicking ok, those files are
reopened.

Help.

- John




All times are GMT +1. The time now is 12:51 AM.

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