How move selection through a .docx document from Matlab?
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (2)
Mario Malic
am 10 Mai 2024
You have mistaken WdGoToItem enumeration, number 4 is for footnote. You need 0 or 11.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Use COM Objects in MATLAB finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!