“There was a problem sending the command to the program”

Excel meme Madagascar penguin Private when you're working in excel and the fan gets a little louder.

“There was a problem sending the command to the program”

Did your blood pressure just rise reading that? We’ve all been there.

This error appeared for me when I had some code that opened another spreadsheet. The code tested for certain items in the other spreadsheet. If a division by zero error occurred, I used the ON ERROR handler to close the other file and then close the current file running the code. Afterward, when I opened the current file again, I saw this pop up.

So what’s happening?

When you open another file with Excel, Microsoft appears to take advantage of something called the Dynamic Data Exchange, which is what Office applications use to communicate with one another. While handling my error, I never actually cleared the error out, I just told Excel to save and quit. Because of this, some error instruction was written into this file’s memory – and when I opened the file again, the error persisted.

Here’s how to fix it:

The most immediate fix is to do a clean start of Excel, and then to deselect “Ignore other applications that use Dynamic Data Exchange (DDE)” from Excel’s options menu. If you have Excel 2010 or 2013, you can find this item by clicking File > Options > Advanced tab > General section. For Excel 2007, click the Office Button > Excel Options > Advanced tab > General section.

How to prevent it:

Make sure to use Err.Clear in your error handler. Don’t let Excel close without handling and clearing all runtime errors. And don’t use ON ERROR to handle errors you can anticipate. Test for those instead. Use ON ERROR for errors you can’t anticipate.

Previous
Previous

Invest In Learning

Next
Next

Book Review: Way of the Wolf