the endless excel does not quit story

S

Sameh Ahmed

Hello there
I am facing that I faced before and a post helped me solve it.
now again I am facing the same problem with Excel as it doe not quit!
here's the code I am using
=================
Dim xapp As New Microsoft.Office.Interop.Excel.Application ' also used
ApplicationClass and it did not work either
Dim xbook As Microsoft.Office.Interop.Excel.Workbook
xbook = xapp.Workbooks.Open(ofd.FileName) ' gets the file name from an
openfiledialog
Dim i = 1
Dim field
For i = 1 To 5
field = xbook.Application.Cells(i, 1).value()
lv.Items.Add(field)
Next
xbook.Close()
xapp.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComObject(xbook)
System.Runtime.InteropServices.Marshal.ReleaseComObject(xapp)
xapp = Nothing
xbook = Nothing
=================
Thanks in advance
Sameh
 
M

Mike Walker

Its possible that the xbook has a similar issue like word in that the
workbook is dirty and requires a save there is a property on the close
method in word wdDoNotSaveChanges or something similar that is optional that
will likely help - the set the xapp and xbook to nothing I think I don't
think will help.

If you still have the problem I will look into this further

Rgds

Mike Walker
(Please reply via NG)
 
C

Chad DeMeyer

Sameh,

Have you tried just deleting the parentheses from the Quit method? Since
you are specifying no arguments, there is no need for the parentheses; and
even if you were specifying arguments, the correct way to specify those
arguments would be "xapp.Quit arg1, arg2" rather than "xapp.Quit(arg1,
arg2)" unless assigning a return value of the method to a variable; and I
don't think the Quit method will return a value.

Hope this helps

Regards,
Chad
 
S

Sameh Ahmed

hey Chad
hey Mike
Regarding the donotsave method, I did not find anything similar under
interop.excel
But there was a property called saved, I tried setting it to true but that
did not help also.
as for removing the parentheses from the quit method, the editor insists on
putting them!
I tried deleting them and it just retypes then again quit(Nothing) does not
make senses and is refused on all cases.!
Thanks in advance.
Regards
Sameh
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top