MATLAB: Word automation – adding / editing tables from matlab

beer

Hi, I'm adding word tables using
MATLAB CODE
newtable = tableRange.ConvertToTable();
After this if I type
MATLAB CODE
newtable.Columns.Count
I get the correct answer, 22. BUT if I try and seelct a column via, say,
MATLAB CODE
newtable.Columns(1).Select();
the whole table is selected (!). Then, if I do
MATLAB CODE
col = newtable.Columns(1)
col has a type "columns" as if the index does not work and
MATLAB CODE
col = newtable.Columns(1).Count
agian returns 22.
Interestingly
MATLAB CODE
newtable.Columns(2).Select
Returns "Index exceeds matrix dimensions.".
It's almost like the index (1) etc is being ignores.
Can anyone help me on this please – for the best performance I really need to be able to quickly select entire columns without using MoveDown etc.
Tom

Best Answer

I believe Columns is a Collection and that you need to do the following to access individual columns:
newtable.Columns.Item(1)
newtable.Columns.Item(2)
I believe Microsoft's COM interfaces do not support indexing into Collections directly with integers or strings the way VBA does.
Good luck, Eric