How move selection through a .docx document from Matlab?
6 ビュー (過去 30 日間)
古いコメントを表示
Hello everyone, I've to write a report in MS word from Matlab and I'm using actxserver('Word.Application') and, despite of some material found on the internet, I can't move the selection to a given point of my document. I load a template .docx I subsequently need to modify and interact with.
Here is my MWE (it doesn't work since I am not allowed to upload .docx file)
% Template path
tmpl_path = 'C:\Users\user_name\Desktop\template_report.docx'
% Create a new Word document from the template
word = actxserver('Word.Application'); % it's a Matlab function
word.visible=1;
doc = word.Documents.Add(tmpl_path);
Tried to use the following command based on this documentation
word.Selection.GoTo(4, 1, [], [])
In the command window I get "ans = Interface.0002095E_0000_0000_C000_000000000046". But in the .docx window the selection is standstill at the beginning of the document
while I need to move it at the beginning of the second section.
0 件のコメント
回答 (2 件)
Mario Malic
2024 年 5 月 10 日
You have mistaken WdGoToItem enumeration, number 4 is for footnote. You need 0 or 11.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Use COM Objects in MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!