LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
Zoo Zoo is offline
external usenet poster
 
Posts: 40
Default How can I detect .xls closing? Not BeforeClose , Like AfterClose?

My .xls file connects to a Oracle Server.
And I want to keep the connection alive while the file is alive.

So I wrote the code like below.

-- a.xls --

Public oCon As Object
Private Sub Workbook_Open()
Set oCon = CreateObject("ADODB.Connection")
oCon.Open "DataSourceName", "ID", "PASSWORD"
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
oCon.Close
Set oCon = Nothing
End Sub



But there's a problem.
When I open xls files , i.e , a.xls (the file mentioned above) , b.xls
(ordinary xls file) , c.xls (ordinary xls file),
and edit b.xls or c.xls ?
Workbook_BeforeClose of a.xls runs , and after that , I'm asked to
overwrite b.xls (or c.xls) , then I cancel the operation.
In this case, after all, a.xls is still opend , but the connection is
already lost.

How I can turn aroud this?
I don't want to connect the server again.
My client wants not to disturb the server log.
For him,repeating connection and disconnection is disturbing the log.

(By the way , I posted similar topic before this.
At that time, I developed xla file.
Concerning xla file , the same problem can be avoided using Deactivate
event.
But , concerning xls file, deactivate event is not useful because it is
raised so much.)

 
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
beforeclose placement Curt Excel Discussion (Misc queries) 9 August 27th 07 08:00 PM
EnableEvents BeforeClose Stefi Excel Programming 2 November 16th 05 09:22 AM
BeforeClose Problem [email protected] Excel Programming 1 October 6th 05 02:15 PM
BeforeClose vs Auto_Close [email protected] Excel Programming 16 June 3rd 05 10:06 PM
How to get out of BeforeClose event without closing? 42N83W Excel Programming 4 March 11th 05 05:33 PM


All times are GMT +1. The time now is 10:09 PM.

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

About Us

"It's about Microsoft Excel"