I've written PB8 code to replace a VBA subroutine I wrote for Excel 2003. It involves passing a couple of large arrays to a PB DLL (one STRING and one LONG), crunching on them for awhile and passing them back to Excel.
When I execute the Excel routine, it calls the PB DLL as required, everything works properly and I get a good result back.
The problem is that if I call the DLL a second or third time it will cause Excel to crash with the error statment "Excel has encountered a problem and needs to close".
So I've been picking at the problem. I observe that when I run the DLL, the Windows Task Manager shows the DLL routine come into being and run as expected. But when the DLL terminates and passes control back to Excel, Task Manager still shows the DLL as "Running". Hmm...
I can make things ok, if every time I run the DLL I then tell Excel to open its VBE and click "Reset" to tell the VBA macro to stop running (even though it's already stopped properly and isn't running) and then close the VBE again. At that point the Task Manager says that the DLL is gone. And I can execute the DLL again from Excel if I wish. I can do this any number of times without Excel crashing.
Yet if I don't go in and manually kill the VBA (that's already stopped), then the DLL stays in the Task Manager and running the DLL a second time kills Excel - or sometimes the second pass works but the third kills Excel.
Does this sound familiar to anyone? Is there some way I can automate Excel to release the DLL so I can invoke it again?
Thanks.
Bill
When I execute the Excel routine, it calls the PB DLL as required, everything works properly and I get a good result back.
The problem is that if I call the DLL a second or third time it will cause Excel to crash with the error statment "Excel has encountered a problem and needs to close".
So I've been picking at the problem. I observe that when I run the DLL, the Windows Task Manager shows the DLL routine come into being and run as expected. But when the DLL terminates and passes control back to Excel, Task Manager still shows the DLL as "Running". Hmm...
I can make things ok, if every time I run the DLL I then tell Excel to open its VBE and click "Reset" to tell the VBA macro to stop running (even though it's already stopped properly and isn't running) and then close the VBE again. At that point the Task Manager says that the DLL is gone. And I can execute the DLL again from Excel if I wish. I can do this any number of times without Excel crashing.
Yet if I don't go in and manually kill the VBA (that's already stopped), then the DLL stays in the Task Manager and running the DLL a second time kills Excel - or sometimes the second pass works but the third kills Excel.
Does this sound familiar to anyone? Is there some way I can automate Excel to release the DLL so I can invoke it again?
Thanks.
Bill
Comment