How to use MoveDown method to move down Tables?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Madalena Lacerda
le 17 Mai 2017
Commenté : Guillaume
le 27 Mai 2017
Hi,
I'm using the ActiveX server and I have to insert some *.PNG pictures in specific table/row locations in a Word Document. I've already tested several approaches and I am now trying to insert them by using the MoveDown method. However, I've tried to use the WdUnits given in:
https://www.mathworks.com/matlabcentral/answers/165541-how-can-i-set-the-movedown-method-to-move-down-paragraphs-headings
And it is not working. If I type in: selection.MoveDown(15,1,0);
To move down one table, MatLab gives this error:
Error using Interface.00020975_0000_0000_C000_000000000046/MoveDown Invoke Error, Dispatch Exception: Source: Microsoft Word Description: Bad parameter Help File: wdmain11.chm Help Context ID: 9018
But if I type in: selection.MoveDown(5,1,0);
To move down one paragraph, it works. But for what I’m doing it is not feasible at all. Can someone help me with this?
Thanks!
0 commentaires
Réponse acceptée
Guillaume
le 17 Mai 2017
Modifié(e) : Guillaume
le 17 Mai 2017
I suspect you get an error because moving down one table is not valid in the current selection context (is there more than one table?).
Unfortunately, I find manipulating word selection programatically infuriating as Microsoft documentation is severely lacking in details. You end up finding something that works by trial and error.
Is it really from table to table that you want to move, rather than table cell to table cell? If the latter, I'd get the table cell without involving selection and set the selection to the content of that cell:
word = actxserver('Word.Application');
selection = word.Selection; %acquire selection reference
%...
table = wdoc.Tables.Item(n); %where wdoc is your word document, and n the index of the table
table.Cell(row, column).Range.Select; %move selection to specific row and column of table
selection.TypeText('Hello world!') %do something with selection
If it's table to table, I'd still use the same principle (index the table collection, get selection from table object).
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur ActiveX dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!