How move selection through a .docx document from Matlab?
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (2)
Mario Malic
il 10 Mag 2024
You have mistaken WdGoToItem enumeration, number 4 is for footnote. You need 0 or 11.
0 Commenti
Vedere anche
Categorie
Scopri di più su Use COM Objects in MATLAB in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!