Azzera filtri
Azzera filtri

Actxserver unable to find 'Workbooks'

1 visualizzazione (ultimi 30 giorni)
waleed khalid
waleed khalid il 10 Mar 2021
Risposto: Vatsal il 5 Giu 2024
Hi, I am trying to create an output excel file to load data into while using Actxserver. For some reason, I cannot find the 'Workbooks' class. Here is my error and code:
results = actxserver ('Excel.Application');
invoke(results.Workbooks, 'add');

Risposte (1)

Vatsal
Vatsal il 5 Giu 2024
Hi,
It seems like you are trying to create an Excel file using MATLAB’s actxserver function. The error message encountered is due to MATLAB not recognizing 'Workbooks' as a property of the results object.
In MATLAB, the actxserver function returns a handle to an instance of a COM object, in this case, Excel. To access the 'Workbooks' property of the Excel application object, dot notation should be used instead of trying to invoke it as a method.
Here is an example of how this might be done:
% Create Excel COM server
Excel = actxserver('Excel.Application');
% Add a new workbook
Workbook = Excel.Workbooks.Add;
I hope this helps!

Categorie

Scopri di più su Use COM Objects in MATLAB in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by