MATLAB: Error while deploying excel add-in

excel add-in

Hello,
Has anyone ever met an error "Method 'Load' of object 'IMWDispatchDriver' failed" while deploying excel add-in?
The code is really simple, so the error is likely to be somewhere in project settings.
Thanks

Best Answer

Hi,
thats an evil bastard of error. The error isn't located on the MATLAB side directly.
  1. Make sure the correct mwcomutil.dll and mwcommgr.dll are registered. You can check that in the registry or which is easier in EXCEL itself. Open up the VBA editor (ALT + F11) and go to (not sure how this is called in English) Tools => References. In that list scroll down to the "MWComMgr n.m Type Library", where n and m is the version of the MATLAB version you are trying to use, e.g. "MWComMgr 8.0 Type Library" would be 12b. Click on that entry and check the path to the DLL Excel gives you. Make sure the DLL path is the correct one (so MATLAB/MCR installation is the correct one) and bittedness matches your Excel bittedness. Do the same for the "MWComUtil n.m Type Library". If one path is wrong or an entry is missing register the appropriate dll file using the regsvr32 command of Windows (you need admin rights for that).
  2. Make sure Excel uses the correct functionwizzard.xlam => This is most likely wrong and tricky to check/resolve. Excel sometimes keep the old/wrong reference. To check that open your registry and navigate to: HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Excel\options (the 14.0 is the Version of Excel, 14.0 = Excel 2010). In there you have an entry called OPEN, OPEN1 etc. Check if it points to the correct xlam, e.g. for me OPEN1 points to "C:\Program Files (x86)\MATLAB\R2012a\toolbox\matlabxl\matlabxl\win32\FunctionWizard2007.xlam". If it points to the wrong xlam, delete that OPEN entry and open Excel again. Now you need to install the FunctionWizzard Add-In again but this time Excel will use the correct version.