I made dll in 64bit environment using deploytool of Matlab. The same functions and command works well in 32 bit environment.
What I have miised?
The vba code
Dim MCLUtil As Object
Dim bModuleInitialized As Boolean
Dim xlmagicclass As Object
Private Sub InitModule()
If Not bModuleInitialized Then
On Error GoTo Handle_Error
If MCLUtil Is Nothing Then
Set MCLUtil = CreateObject("MWComUtil.MWUtil")
End If
Call MCLUtil.MWInitApplication(Application)
bModuleInitialized = True
Exit Sub
Handle_Error:
bModuleInitialized = False
End If
End Sub
Sub mymagic()
Dim R1 As Range 'Input value
Dim R2 As Range 'Output range
On Error GoTo Handle_Error
Call InitModule
Set R1 = Range("A2") 'Specify where the input value is.
Set R2 = Range("B2:E5") 'Specify that range for the output to use.
If xlmagicclass Is Nothing Then
Set xlmagicclass = CreateObject("xlmagic.xlmagicclass.1_0")
End If
Call xlmagicclass.mymagic(1, R2, R1)
Exit Sub
Handle_Error:
MsgBox ("Error: " & Format(Err.Number) & " Source: " & Err.Source & " Message: " & Err.Description)
End Sub
The matlab code
function y = mymagic(x)
y = magic(x)
The error message
Error: -2147467259 Source: xlmagic.xlmagicclass.1_0 Message:
It has been resolved by two step.
Simply install "MyAppInstaller_web" file in the for_redistribution folder.
And run the _install batch file in for_redistribution_files_only folder.