MS-Word Office.js equivalent for `Selection.MoveRight` function in VBA

Viewed 59

I'm converting from VBA to Office.js and I'm unable to find an office.js function for Word that is equivalent to Selection.MoveRight function in VBA. Is there a simple way to do similar things?

For example, I have a string of characters and inline images, and I would like to move right for designated N characters (including inline images), then insert a line break:

Example

This is easy to do in VBA like below. How could I do the same thing in office.js?

Selection.MoveRight Unit:=wdCharacter, Count:= N
Selection.TypeParagraph
1 Answers

There is no equivalent for MoveRight in the Office JavaScript library. Something you might try to get the results you want:

Use the Range.getOOXML() method to get the underlying OOXML of the range. Add OOXML line breaks. Then use Range.insertOOXML() to replace the original range with the new one.

Related