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 spread sheets do not close from vb.net

I wrote a program in vb.net 2005 to open a spread sheet, read data and then
close the spreadsheet. The probelm is it is not really closing.

Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet

' OPEN WORKSHEET AND DO STUFF

xlBook.Application.Visible = True
xlBook.Windows(1).Visible = True
xlBook.Application.WindowState = Excel.XlWindowState.xlMinimized

' Call loadSheet(xlbook.Worksheets(SheetName))

xlBook.Close(True)
xlApp.Quit()
NAR(xlBook)
NAR(xlApp)



Private Sub NAR(ByVal o As Object)
Try
System.Runtime.InteropServices.Marshal.ReleaseComO bject(o)
Catch ex As Exception
Finally
o = Nothing
End Try
End Sub


Can someone tell me what I am doing wrong?

--
Arnie
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default Excel spread sheets do not close from vb.net

Not really sure, but maybe you should release the workbook before trying to
quit the application, in other words, reverse these two steps:

xlApp.Quit()
NAR(xlBook)


- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Arniec" wrote in message
...
I wrote a program in vb.net 2005 to open a spread sheet, read data and then
close the spreadsheet. The probelm is it is not really closing.

Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet

' OPEN WORKSHEET AND DO STUFF

xlBook.Application.Visible = True
xlBook.Windows(1).Visible = True
xlBook.Application.WindowState =
Excel.XlWindowState.xlMinimized

' Call loadSheet(xlbook.Worksheets(SheetName))

xlBook.Close(True)
xlApp.Quit()
NAR(xlBook)
NAR(xlApp)



Private Sub NAR(ByVal o As Object)
Try
System.Runtime.InteropServices.Marshal.ReleaseComO bject(o)
Catch ex As Exception
Finally
o = Nothing
End Try
End Sub


Can someone tell me what I am doing wrong?

--
Arnie



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
Multiple Excel Spread Sheets TC Excel Discussion (Misc queries) 3 January 4th 10 11:53 PM
cant open SAVED excel spread sheets Anthony[_2_] Excel Discussion (Misc queries) 2 April 6th 07 01:14 PM
how do i look up and create excel spread sheets marti Excel Worksheet Functions 1 December 16th 06 08:24 PM
Updating 2 excel spread sheets? alexm999 Excel Discussion (Misc queries) 1 March 17th 06 12:06 AM
how do I get a download for excel spread sheets only fmj distributing Excel Discussion (Misc queries) 3 February 18th 05 09:16 AM


All times are GMT +1. The time now is 11:13 AM.

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

About Us

"It's about Microsoft Excel"