e.Workbook​s.open(FIL​E_NAME);

every time I try the 'Open'
FILE_NAME = 'E:\Nov_2017\CP-140_NOV-17\1_FORCE_DATA.xls'
eWorkbook = e.Workbooks.open(FILE_NAME);
command, it comes back with: Error using open Too many input arguments.
any idea why?

6 Commenti

What are the lines just before that, creating e ? Is it
e = actxserver('Excel.Application');
Dennis Bellamy comment posted as an answer moved here:
Yes, the segment of code that I am trying to get to work is:
e = actxserver('Excel.Application');
% Add a workbook.
eWorkbook = e.Workbooks.open(FILE_NAME);
e.Visible = 1;
% Make the first sheet active.
eSheets = e.ActiveWorkbook.Sheets;
eSheet1 = eSheets.get('Item',1);
eSheet1.Activate
% Merge Cells (NOMRAL)
eSheet1 = eSheet1.get('Range', 'A1:D1');
eSheet1.MergeCells = 1;
eSheet1.Value = Titles(1);
% eSheet1.Font.ColorIndex = 3
eSheet1.Font.Bold = 1;
% Merge Cells (TANGENT)
eSheet1 = eSheet1.get('Range', 'E1:H1');
eSheet1.MergeCells = 1;
eSheet1.Value = Titles(2);
% eSheet1.Font.ColorIndex = 3
eSheet1.Font.Bold = 1;
% Merge Cells (NOMRAL)
eSheet1 = eSheet1.get('Range', 'I1:L1');
eSheet1.MergeCells = 1;
eSheet1.Value = Titles(3);
% eSheet1.Font.ColorIndex = 3
eSheet1.Font.Bold = 1;
I do apologize, should have sent the whole block in the first place.
Guillaume
Guillaume il 30 Nov 2017
Modificato: Guillaume il 30 Nov 2017
Can you show the output of
methods(e.Workbooks, '-full')
The code you've posted should work fine. For safety, I would replace the line
eSheets = e.ActiveWorkbook.Sheets;
by
esheets = eWorkbook.Sheets;
But that is irrelevant to your problem as it's after the location where the error occurs.
Dennis Bellamy
Dennis Bellamy il 30 Nov 2017
Modificato: Guillaume il 30 Nov 2017
here is the output:
methods(e.Workbooks, '-full')
Methods for class Interface.000208DB_0000_0000_C000_000000000046:
handle Add(handle, Variant(Optional))
bool CanCheckOut(handle, string)
CheckOut(handle, string)
Close(handle)
handle Item(handle, Variant)
handle Open(handle, string, Variant(Optional))
handle OpenDatabase(handle, string, Variant(Optional))
OpenText(handle, string, Variant(Optional))
handle OpenXML(handle, string, Variant(Optional))
addproperty(handle, string)
delete(handle, MATLAB array)
deleteproperty(handle, string)
MATLAB array events(handle, MATLAB array)
MATLAB array get(handle)
MATLAB array get(handle, MATLAB array, MATLAB array)
MATLAB array get(handle vector, MATLAB array, MATLAB array)
MATLAB array invoke(handle)
MATLAB array invoke(handle, string, MATLAB array)
MATLAB array loadobj(handle)
release(handle, MATLAB array)
MATLAB array saveobj(handle)
MATLAB array set(handle)
MATLAB array set(handle, MATLAB array, MATLAB array)
MATLAB array set(handle vector, MATLAB array, MATLAB array)
I have tried all manner of re-entering the name, it just keeps coming back with the same error...
thanks for your help... but still not working.
Notice it has Open with a capital 'O'.
In my defence, I am working on three blocks of code and LaTex trying to get this data filtered, saved, and charted....
Probably should have noticed that myself so THANK YOU for pointing it out....
next question, how do I get the merged cell to centre the data? and can I make charts in Excel directly from MATLAB? and finally, is there an index of commands that I can use with e.Workbooks so that I can find these answers on my own?
thanks again for your help.

Accedi per commentare.

Risposte (1)

Greg
Greg il 1 Dic 2017

0 voti

For simple stuff, use properties(e) and methods(e) as Guillaume has indicated, with the extra knowledge that Microsoft Office products are (almost?) always capitalized, and MATLAB often start lowercase.
For more involved stuff, open Excel (or Office application of your choice), and change your help to "Developer Reference" then click "Excel Object Model Reference." You can browse a VAST library of VBA/API information this way (and without an internet connection). See attached image.

Richiesto:

il 29 Nov 2017

Risposto:

il 1 Dic 2017

Community Treasure Hunt

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

Start Hunting!

Translated by