ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Repost Excel Crashes on Workbook close!! (https://www.excelbanter.com/excel-programming/336260-repost-excel-crashes-workbook-close.html)

James Wellington

Repost Excel Crashes on Workbook close!!
 
I have been experiencing a strange problem when closing one of my workbooks
which connects to the SQL server via ado. After the workbooks with code is
closed if another workbook is open and I click on another workbook, excel
will crash. If however I click on outlook or another office application,
bring it to focus and then go back to excel its fine. I have checked to
make
sure all object are being released. Any ideas... James--------------

Make sure your code has some DoEvents in (2 or 3 sometimes) before it ends
to allow Excel to clear the message queue. Also make sure you do not
reference any forms, or if you do make sure to set everything to nothing.

I have had similar probs, eventually I think it ended up being an implicit
reference to a function in a form (should have been in a module anyway).

cheers
Simon


--------------Added a couple of DoEvents and still having the same problem.
There are no forms involved just querying the SQL Server using ADO and
running it through some formulas and closing the workbook. When closing the
workbook if I have excel save the workbook this problem goes away but if I
set thisworkbook.close SaveChanges:=False excel will crash after I activate
another workbook.Help is greatly appreciated!!James



Simon Murphy[_4_]

Repost Excel Crashes on Workbook close!!
 
Are you setting all variables to nothing then adding a couple of doevents?

"James Wellington" wrote:

I have been experiencing a strange problem when closing one of my workbooks
which connects to the SQL server via ado. After the workbooks with code is
closed if another workbook is open and I click on another workbook, excel
will crash. If however I click on outlook or another office application,
bring it to focus and then go back to excel its fine. I have checked to
make
sure all object are being released. Any ideas... James--------------

Make sure your code has some DoEvents in (2 or 3 sometimes) before it ends
to allow Excel to clear the message queue. Also make sure you do not
reference any forms, or if you do make sure to set everything to nothing.

I have had similar probs, eventually I think it ended up being an implicit
reference to a function in a form (should have been in a module anyway).

cheers
Simon


--------------Added a couple of DoEvents and still having the same problem.
There are no forms involved just querying the SQL Server using ADO and
running it through some formulas and closing the workbook. When closing the
workbook if I have excel save the workbook this problem goes away but if I
set thisworkbook.close SaveChanges:=False excel will crash after I activate
another workbook.Help is greatly appreciated!!James




Simon Murphy[_4_]

Repost Excel Crashes on Workbook close!!
 
did you close all connections properly?

"James Wellington" wrote:

I have been experiencing a strange problem when closing one of my workbooks
which connects to the SQL server via ado. After the workbooks with code is
closed if another workbook is open and I click on another workbook, excel
will crash. If however I click on outlook or another office application,
bring it to focus and then go back to excel its fine. I have checked to
make
sure all object are being released. Any ideas... James--------------

Make sure your code has some DoEvents in (2 or 3 sometimes) before it ends
to allow Excel to clear the message queue. Also make sure you do not
reference any forms, or if you do make sure to set everything to nothing.

I have had similar probs, eventually I think it ended up being an implicit
reference to a function in a form (should have been in a module anyway).

cheers
Simon


--------------Added a couple of DoEvents and still having the same problem.
There are no forms involved just querying the SQL Server using ADO and
running it through some formulas and closing the workbook. When closing the
workbook if I have excel save the workbook this problem goes away but if I
set thisworkbook.close SaveChanges:=False excel will crash after I activate
another workbook.Help is greatly appreciated!!James




James Wellington

Repost Excel Crashes on Workbook close!!
 
Simon,
Yes, all variables are set to nothing. I have put DoEvents after the
queries and in the beforeclose event.

James


"Simon Murphy" wrote in message
...
Are you setting all variables to nothing then adding a couple of doevents?

"James Wellington" wrote:

I have been experiencing a strange problem when closing one of my
workbooks
which connects to the SQL server via ado. After the workbooks with code
is
closed if another workbook is open and I click on another workbook, excel
will crash. If however I click on outlook or another office application,
bring it to focus and then go back to excel its fine. I have checked to
make
sure all object are being released. Any ideas... James--------------

Make sure your code has some DoEvents in (2 or 3 sometimes) before it
ends
to allow Excel to clear the message queue. Also make sure you do not
reference any forms, or if you do make sure to set everything to nothing.

I have had similar probs, eventually I think it ended up being an
implicit
reference to a function in a form (should have been in a module anyway).

cheers
Simon


--------------Added a couple of DoEvents and still having the same
problem.
There are no forms involved just querying the SQL Server using ADO and
running it through some formulas and closing the workbook. When closing
the
workbook if I have excel save the workbook this problem goes away but if
I
set thisworkbook.close SaveChanges:=False excel will crash after I
activate
another workbook.Help is greatly appreciated!!James







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

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