How can I fix the "Unable to Start MATLAB. Please register MATLAB Software as a COM Server." error?

13 views (last 30 days)
I am trying to connect to MATLAB using Spreadsheet Link using R2020b. I have just upgraded from R2020a where it was working and now, when I try opening MATLAB from Excel, I am getting following error
"Unable to Start MATLAB. Please register MATLAB Software as a COM Server."
When I tried going back to R2020a, it stopped working there too.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 13 Oct 2020
Before following the steps below, this issue might be caused by security. The following steps should be attempted if a security issue is an unlikely cause:
1. Since Spreadsheet Link is trying to open an instance of R2020b, it is important first check if a new instance of MATLAB can be opened from MATLAB as a COM server. Regardless of the version of MATLAB from which it is called, in the Command Window, executing
>> actxserver('matlab.desktop.application')
should open a new instance of MATLAB, and ideally R2020b. If a new instance of the desktop version of R2020b does not open, check what is returned by:
>> comserver('query')
In the two paths printed under User and Administrator should have R2020b in them. By default it might be:
User: 'C:\Program Files\MATLAB\R2020b\bin\win64\matlab.exe'
Administrator: 'C:\Program Files\MATLAB\R2020b\bin\win64\MATLAB.exe'
If this is not the case, close MATLAB, re-open MATLAB R2020b as an administrator, and execute
>> comserver('unregister', 'User', 'all')
>> comserver('unregister')
which will unregister MATLAB as a COM server. Close all instances of MATLAB and relaunch R2020b as an administrator. This will ensure that only the active MATLAB session of R2020b will be re-registered as a COM server. Then, execute:
>> regmatlabserver
>> comserver('query')
User: ''
Administrator: 'C:\Program Files\MATLAB\R2020b\bin\win64\MATLAB.exe'
 
2. Assuming there are no other instances of MATLAB running, calling
>> actxserver('matlab.desktop.application')
from either R2020a or R2020b (while still in administrator mode) will launch R2020b. Since MATLAB can now be launched as a COM server from MATLAB, it can also be done from Excel.
3. In a new Excel workbook, create a new VBA module by going to the Developer tab in the ribbon and clicking on the "Visual Basic" item. In there, create a new module under "Sheet1" and paste in the following code:
Dim matlabtest As Object
Sub testmatlab()
Set matlab = Nothing
Set matlabtest = CreateObject("Matlab.Desktop.Application")
MsgBox ("Check MATLAB")
End Sub
Before running this, make sure that all instances of MATLAB are closed again. This short VBA subroutine tries to create an instance of MATLAB using "CreateObject" which is the simplest way to start MATLAB as a COM server from Excel. If the subroutine fails to run, there is likely a security issue where a third party application or firewall is preventing Excel from running any scripts. If this succeeds and a new instance of R2020b opens, then Spreadsheet Link should be working as well.

More Answers (0)

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!