Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2008

Tip: Looking for answers? Try searching our database.

Excel spread sheets do not close from vb.net

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Arniec - 16 Jan 2008 23:41 GMT
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.ReleaseComObject(o)
       Catch ex As Exception
       Finally
           o = Nothing
       End Try
   End Sub

Can someone tell me what I am doing wrong?

Signature

Arnie

Jon Peltier - 17 Jan 2008 03:28 GMT
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
_______

>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.
[quoted text clipped - 27 lines]
>
> Can someone tell me what I am doing wrong?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.