Connecting to COM server from VBA fails????

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???

Answers (0)

Asked:

dpb
on 11 Apr 2015

Edited:

dpb
on 12 Apr 2015

Community Treasure Hunt

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

Start Hunting!