IMessageFilter for BackgroundWorker [Excel]

-1

I'm currently getting the following error when running the below code:
Error:

COMException was unhandled
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll

Additional information: Call was rejected by callee. (Exception from HRESULT: 0x80010001 (RPC_E_CALL_REJECTED))

Code:

 Sub DisplayInfo()
      txtSample1.Text = worksheet.Cells(((CurrentPage * 8) + 1), 3).Value



I suspect that this is a result of this background worker:

Private Sub bwSaveAndLoad_DoWork(sender As Object, e As DoWorkEventArgs) Handles bwSaveAndLoad.DoWork
     Try
          workbook.Save()
     Catch
     End Try
End Sub

Here's the WorkCompleted for the DoWork:

Private Sub bwSaveAndLoad_RunWorkerCompleted(sender As Object, e As RunWorkerCompletedEventArgs) Handles bwSaveAndLoad.RunWorkerCompleted
    Call DisplayInfo()


After a long and tedious conversation with Google, I was informed that I need to implement an IMessageFilter error handler. I took a look at the documentation for it, and I still have no idea how to do this. Would someone be able to point me in the right direction?

.net
asked on Stack Overflow Mar 3, 2017 by lolikols

1 Answer

1

Great example here. I wasn't aware that I was looking for CoRegisterMessageFilter. This whole time I was only Googling IMessageFilter, but this works beautifully!:

http://dl2.plm.automation.siemens.com/solidedge/api/sesdk_web/OleMessageFilterUsage.html

answered on Stack Overflow Mar 3, 2017 by lolikols

User contributions licensed under CC BY-SA 3.0