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!