471,337 Members | 860 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,337 software developers and data experts.

Excel Interop problem

Hello,

I am using Excel Interop to export data from a dataset to an excel-file.
Everything works fine except closing the excel-file.

I have an Application-object and a Workbook-object. I call the Close
method on the Workbook en the Quit on the Application.

My program works fine but after my program is closed, I can still see
Excel running as a process on my pc, this gives troubles when shutting
down the pc.

Anyone who has an idea?

Thanks,
Dries
Jan 7 '06 #1
4 1597
hi Dries,

well i think in ur case u can use
System.Runtime.InteropServices.Marshal.ReleaseComO bject()

this method to release the COM object whenever you close the
application which should Dispose the EXCEL application object.

call it in your form closing event when u finish working with EXCEL
application object and run this loop in the event. pass your EXCEL
Application object to the method.

While System.Runtime.InteropServices.Marshal.ReleaseComO bject("Excel
Application Object") = 0
End While

Jan 7 '06 #2
hi Dries,

well i think in ur case u can use
System.Runtime.InteropServices.Marshal.ReleaseComO bject()

this method to release the COM object whenever you close the
application which should Dispose the EXCEL application object.

call it in your form closing event when u finish working with EXCEL
application object and run this loop in the event. pass your EXCEL
Application object to the method.

While System.Runtime.InteropServices.Marshal.ReleaseComO bject("Excel
Application Object") = 0
End While

Jan 7 '06 #3
Lucky wrote:
hi Dries,

well i think in ur case u can use
System.Runtime.InteropServices.Marshal.ReleaseComO bject()

this method to release the COM object whenever you close the
application which should Dispose the EXCEL application object.

call it in your form closing event when u finish working with EXCEL
application object and run this loop in the event. pass your EXCEL
Application object to the method.

While System.Runtime.InteropServices.Marshal.ReleaseComO bject("Excel
Application Object") = 0
End While

thanks, it works
Jan 7 '06 #4
That's really only a partial solution. See
http://support.microsoft.com/default...;EN-US;q317109 for an
explanation.

Use the following:

Private Sub NAR(ByVal o As Object)

Dim refCount As Int32

Try

Do

refCount = System.Runtime.InteropServices.Marshal.ReleaseComO bject(o)

Loop While refCount > 0

Catch

Finally

o = Nothing

End Try

End Sub

"Lucky" <tu************@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
hi Dries,

well i think in ur case u can use
System.Runtime.InteropServices.Marshal.ReleaseComO bject()

this method to release the COM object whenever you close the
application which should Dispose the EXCEL application object.

call it in your form closing event when u finish working with EXCEL
application object and run this loop in the event. pass your EXCEL
Application object to the method.

While System.Runtime.InteropServices.Marshal.ReleaseComO bject("Excel
Application Object") = 0
End While

Jan 8 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

17 posts views Thread by Mansi | last post: by
1 post views Thread by Bernd Muent | last post: by
4 posts views Thread by goonsquad | last post: by
3 posts views Thread by James Wong | last post: by
reply views Thread by liam_jones | last post: by
3 posts views Thread by KaNos | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.