How to use MoveDown method to move down Tables?
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Guillaume
2017-5-17
编辑:Guillaume
2017-5-17
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).
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 ActiveX 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!