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.
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).
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.
Check the version of MWComUtil type-library that is referenced by the VBA macro. There is a possiblility that after installing the newer version of MATLAB, the newer version of MWComUtil is being referenced and thus is incompatible with the add-in which was created against the older version of the DLL.
You may need to re-register the older version of MWComUtil, the one that corresponds to R2007b, in the DOS shell as follows:
This bug has been fixed for Release 14 SP1 (R14SP1). For previous releases, please read below for any possible workarounds:
We have verified that there is an error in the documentation for MATLAB Builder for COM 1.1 (R14) and MATLAB Builder for Excel 1.2 (R14) in the references it states must be selected.
To work around this issue, try unselecting the MWComUtil 1.0 Type Library and then selecting the MWComUtil 7.0 Type Library and the MWComMgr 7.0 Type Library.
Best Answer