Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel opened by program and closed by user

How can I catch if the USER closes Excel which I opened from the
external application in VB.NET?

Users can open and interact with a spreadsheet, but how can I tell
when
they close Excel?
I need to set my variables (xlApp) to nothing and do other stuff

Thanks!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,117
Default Excel opened by program and closed by user

you could use an automatic before_close macro to reset all your
variables, etc..... although i'm not sure if that will work in vb.net.

Private Sub Workbook_BeforeClose (Cancel as Boolean)

.... your code...

End sub

susan


On Mar 22, 1:37 pm, wrote:
How can I catch if the USER closes Excel which I opened from the
external application in VB.NET?

Users can open and interact with a spreadsheet, but how can I tell
when
they close Excel?
I need to set my variables (xlApp) to nothing and do other stuff

Thanks!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Excel opened by program and closed by user

In VB, I'd use a With Events

Dim WithEvents XLApp As Excel.Application

Private Sub CommandButton1_Click()
Set XLApp = New Excel.Application
End Sub

Private Sub XLApp_WorkbookBeforeClose(ByVal Wb As Workbook, Cancel As
Boolean)
MsgBox "Closing WB: " & Wb.Name
End Sub

However, I would have thought that as your app holds a reference to the
XLApp, the XL instance cannot close, although the user may dimiss the UI.
There is no Excel event like "Excel_BeforeClose"

Is this for an addin ?

NickHK

wrote in message
oups.com...
How can I catch if the USER closes Excel which I opened from the
external application in VB.NET?

Users can open and interact with a spreadsheet, but how can I tell
when
they close Excel?
I need to set my variables (xlApp) to nothing and do other stuff

Thanks!



Reply
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
How can I start a new excel program for each opened excel file? Amos Setting up and Configuration of Excel 6 April 3rd 09 02:49 PM
Run macro when file is opened and closed mcphc Excel Programming 2 February 20th 07 11:32 AM
How do I tell if user has closed Excel. NickHK Excel Programming 8 January 19th 07 10:15 AM
how do i disable "running virus scan" in excel program when opened Tammy New Users to Excel 1 June 10th 05 08:48 PM
save Wsh to closed/opened WB helmekki[_45_] Excel Programming 1 October 25th 04 08:28 PM


All times are GMT +1. The time now is 07:39 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"