troubleshooting Question

Cannot kill Excel from taskmgr after Excel Export in VB 2014

Avatar of sqdperu
sqdperuFlag for United States of America asked on
Visual Basic.NETMicrosoft 365Windows 7* Export
6 Comments1 Solution214 ViewsLast Modified:
Using VB 2013 on Windows 7 64-bit and Office 365 (Excel) 32 bit.

I have some code that exports a DataGridView to Excel.  The code works fine.
I had an issue with MS Access so I ran a "Quick Repair" on Office 365 and it fixed the Access issue.

Now my Export to Excel still works fine.  However, the code the kills the Excel.exe*32 that likes to hang out in taskmgr now generates an error.


    Declare Function PostMessage Lib "user32" Alias "PostMessageA" _
           (ByVal hwnd As Int32, ByVal wMsg As Int32, ByVal wParam As Int32, ByVal lParam As Int32) As Int32
    Const WM_QUIT As Object = &H12

 Dim xlApp As Excel.Application

... do the Excel export code successfully...


PostMessage(xlApp.Hwnd, WM_QUIT, 0, 0)              <<<<  CODE THAT NOW GENERATES THE ERROR   <<<<<

xlApp = Nothing


Code that I have tried in place of the error generating line of code (this code does absolutely nothing):



Error looks like this:
Error killing EXCEL.EXE*32
Any ideas why this one line of code no longer works after I did a "Quick Repair" on Office 365 and how do I fix it?

What would the code look like to trap this error and "Resume Next"?


Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros