Matlab dll Error : -2147467259 for VBA in 64bit environment

Matlab dll Error : -2147467259 for VBA in 64bit environment

我用Matlab的deploytool在64位环境下制作了dll。 相同的功能和命令在 32 位环境中运行良好。

我错过了什么?

vba代码

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

matlab代码

function y = mymagic(x)
y = magic(x)
The error message

    Error: -2147467259 Source: xlmagic.xlmagicclass.1_0 Message:

两步解决

  1. 只需在for_redistribution文件夹中安装"MyAppInstaller_web"文件。

  2. 和 运行 for_redistribution_files_only 文件夹中的 _install 批处理文件。