Here's some starter code for you. Be aware that this code assumes that, if there are multiple tables, they are all the same size.
word = actxserver('Word.Application');
[filename_in, pathname] = uigetfile({'*.doc;*.docx;*.docm','Word Files (*.doc,*.docx,*.docm)'; ...
'*.*', 'All Files (*.*)'}, 'Select a file');
document = word.documents.Open(fullfile(pathname,filename_in));
r=0;
tbl_cnt = document.Tables.Count;
for tbl = 1 : tbl_cnt
row_cnt = document.Tables.Item(tbl).Rows.Count;
col_cnt = document.Tables.Item(tbl).Columns.Count;
for row = 1 : row_cnt
r = r+1;
for col = 1 : col_cnt
cell_txt = strtrim(document.Tables.Item(tbl).Cell(row, col).Range.Text);
tblVals{r,col} = cell_txt;
end
end
end
document.Close;
word.Quit;
delete(word);
clear word document
Best Answer