MATLAB: Do I receive the error “The first argument ‘channel’ is not valid” when using the function DDEREQ on Windows 64-bit with MATLAB 7.7 (R2008b)

MATLAB

I have code that retrieves data from Excel through the DDE inteface. The code works fine on Windows 32-bit. However, when I run the code on Windows 64-bit, I can only call DDEREQ exactly 63 times, at the 64th time, an error is thrown.
Reproduction steps:
1. Open an Excel file and enter a value in a cell. Define an alias for the cell with the name 'Dummy'. Keep Excel open.
2. Run the following code in MATLAB:
for i=1:100
exChannel = ddeinit('Excel', 'Sheet1');
% Read cell marked as 'Dummy'.
% Crashes at i=64 on Win64.
retValue = ddereq(exChannel, 'Dummy');
rc = ddeterm(exChannel);
clear exChannel;
end
On Windows 64-bit, the following error will occur on the 64th iteration:
??? Error using ==> ddereq
The first argument 'channel' is not valid.

Best Answer

All DDE related functions are obsolete, as this technology has been replaced by the COM/ActiveX interface. For more information, see the Related Solution at the bottom of the page.
To work around this issue, use the capabilities of the function XLSREAD instead:
retValue = xlsread('test.xls', 'Sheet1', 'Dummy')
This workaround also has the advantage of not requiring the Excel file to be open in order to access it. With just one line you can replace three lines that were needed when using the DDE functionality.
For all MATLAB versions > R2007b, all development work for the Dynamic Data Exchange(DDE) server and client was stopped. Mathworks instead, provides a MATLAB interface to the COM technology.