How to read MS word file(*.doc/docx).
33 次查看(过去 30 天)
显示 更早的评论
I have to import data from MS word file and consider the imported file as 'string' but in some case, their are many pictures, images, table etc have into the file. Is it possible to do that in MATLAB or I could have to switch to any other language? Thank YOU
0 个评论
回答(1 个)
Guillaume
2017-7-14
编辑:Guillaume
2017-7-14
The issue is not matlab. You'll have to go through exactly the same difficulties whichever language you use. The issue is more that a Word document is not a simple string. You can certainly extract the various sections of text from a word document in any language but you'll have to work for it.
All the functions to navigate a Word document are documented on MSDN. The most important object for you is the Document object.
This could be a start:
word = actxserver('Word.Application');
wdoc = word.Documents.Open('C:\somewhere\somefile.docx');
%wdoc is the Document object which you can query and navigate.
sometext = wdoc.Content.Text;
3 个评论
Tobias Huth
2018-11-26
Thanks for the help!
One should not forget to close the objects:
wdoc.Close; % close document
word.Quit; % end application
Greetings,
Tobias
Ioonut
2020-4-30
do you know how to extract the pictures from a doc file that has for example 10 pictures inserted?
I understood from MSDN that wdoc.InlineShapes should contain this,but I dont know how I could get a variable like 'picture' or how to index it
picture = wdoc.something(index)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Text Files 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!