Edit Excel files to automatically update into MATLAB
59 views (last 30 days)
Show older comments
I am trying to figure out how to edit an excel file and have those changes automatically update into MATLAB. Currently I am stuck copy and pasting the data into MATLAB to keep those updated numbers. Finally, this excel is in a shared folder on Microsoft Teams. I am unable to download to my drive or import directly to MATLAB because anyone can make that update to change the values.
I've tried "actxserver('excel.application')" but received an error that it's not supported.
Thanks!
7 Comments
dpb
on 7 Aug 2025 at 14:29
Edited: dpb
on 7 Aug 2025 at 17:59
It's the Teams interface that is the kicker; it blocks COM.
I have found it virtually impossible to do anything conventionally externally with shared drive/Teams in control; there's a whole different API set in play there, it appears.
You might consider submiting an official support request to Mathworks and see if they know of any useful tricks; I am not sure you can even manage to open the file from MATLAB without downloading a local copy; the shared url isn't directly accessing the file, but the MS front end application.
I don't know whether you can create a MATLAB addin for the Excel app inside the shared app that could drive the MATLAB app or not.
Answers (1)
dpb
on 7 Aug 2025 at 15:02
Edited: dpb
on 9 Aug 2025 at 17:47
I found a MS link that says you can open the shared file with the local desktop copy of Excel and then use COM through that interface -- I just tried opening a shared file and then used
>> excel=actxGetRunningServer('Excel.Application')
excel =
COM.Excel_Application
>> excel.Workbooks
ans =
Interface.000208DB_0000_0000_C000_000000000046
>> excel.ActiveWorkbook.Name
ans =
'July24GLTemplateUpload.xls'
>> excel.ActiveWorkbook.Close(0)
>> excel.Quit
>> delete(excel)
>> clear excel
and lo! and behold!, it did connect to the existing server and saw the file...I had not realized before now that that actually would work that way.
You would have to have only the one instance running to ensure to connect to the correct one; if there is more than one running, then the OS determines which one is attached to; afaict at least with the MATLAB function there's no way to control which of multiple servers one would get.
But, it would appear this is at least a theoretically possible way to interact with the shared file.
I have scrupulously avoided installing MS Teams, so I can't test just what happens there; the cloud storage and urls instead of resolvable filenames are already too much hassle to try to use with MATLAB that can't resolve those into filenames...and the web interface is too painful by far to use for earnest (or "in anger" as my old Scottish friend used to say about beginning testing in the power plants).
0 Comments
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!