MATLAB: Am I unable to run MATLAB 7.6 (R2008a) from the VB code example in the document using VBA in Excel

91createobjecterrorMATLABsetvba

I am trying to run the VB code example in the "Examples of a MATLAB Automation Server" section of the help document using VBA in Excel.
I get the following error when I try to run it:
Run-time error '91':
Object variable or With block variable not set

Best Answer

The syntax in the code example is related to VB, in order to run this code in the VBA environment from Excel, please change:
MatLab = CreateObject("Matlab.Application")
to
Set MatLab = CreateObject("Matlab.Application")
Please note that the above syntax change is valid for all Microsoft Office products that can execute VBA code.