Problems to call matlab in vba code

11 views (last 30 days)
wladi pat
wladi pat on 17 Jan 2014
Commented: Eric on 24 Jan 2014
Dear all,
I created a dll calling Matlab from vba code. Everything was working well until yesterday... (I do not know what I changed but I must have change something...). I now have an error in my vba code when I try to run the following line:
Private Sub InitModule()
If Not bModuleInitialized Then
modName = "MtlbRiskPremiaComputation_v2012b.MtlbRiskPremiaComputation2012b.1_0"
On Error GoTo Handle_Error
If MCLUtil Is Nothing Then
Set MCLUtil = CreateObject("MWComUtil.MWUtil8.0") %where I got the error message
End If
The error message I have: "Error in VBA project: Automation error ClassFactory cannot supply requested class"
It seems that excel is not able to communicate with Matlab anymore. Do you have any idea where it may come from ? (something related to the compiler ? to the startup file ?)
Thank you in advance for your precious help
  3 Comments
wladi pat
wladi pat on 20 Jan 2014
Thank you Andrew, it is now working !
Eric
Eric on 24 Jan 2014
This error seems isolated to the January 2014 update from Bloomberg. Rolling back to the December 2013 release of Bloomberg allows the code to work as expected. But unfortunately, Bloomberg will eventually self-update to the current release. Unfortunately, the OP's answer about re-registering the DLLs from the runtime and compiled DLL did not do the trick for me. Only a reinstall of the Dec 2013 Bloomberg worked.

Sign in to comment.

Answers (1)

Vignesh
Vignesh on 21 Jan 2014
Edited: Vignesh on 21 Jan 2014
Please re-register the DLL's and use the Excel addin.
regsvr32 <matlabroot>runtime\win32\mwcommgr.dll
regsvr32 <matlabroot>runtime\win32\mwcomutil.dll
regsvr32 <project_dll_dir>\projectdll_1_0.dll
Here, matlabroot corresponds to the folder obtained by executing MATLABROOT in MATLAB command line.
This would re-register the DLLs and did not conflict after enabling the Bloomberg Excel Addin.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!