Connecting to COM server from VBA fails????

7 Ansichten (letzte 30 Tage)
dpb
dpb am 11 Apr. 2015
Bearbeitet: dpb am 12 Apr. 2015
No joy ensues with any of the suggested syntax when execute an Excel macro...
Matlab = New MLApp.MLApp
or
Dim Matlab As Object
MatLab = CreateObject("Matlab.Application")
all return VB error "Object variable or With block variable not set (Error 91)"
I can't seem to get any example code to work to get a connection established. What's the magic incantation I'm missing? R2012b
ADDENDUM
OK, so think I now know why it fails to connect from VB/Excel side...
>> h = actxserver('matlab.application')
h =
COM.matlab_application
>> enableservice('AutomationServer')
ans =
0
>>
but, whassup w/ this?
ADDENDUM 2
OK, mostly this seems to have been a failure in the documentation -- the line
MatLab = CreateObject("Matlab.Application")
is incorrect in the example code, the keyword Set is missing--as the error message indicated; I made the mistake of presuming TMW had tested their sample code. :(
The proper syntax is
Set ML = CreateObject("Matlab.Application")
and as noted, the "Set" is mandatory. After this the VBA test code will function.
At this point have another question if anybody knows anything about this stuff--if look at the libraries from the OLE object viewer, there are two libraries shown
MLApp
IMLApp
with identical methods -- anybody got any klew as to what the difference is/reason for two???

Antworten (0)

Kategorien

Mehr zu Use COM Objects in MATLAB finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by