0
votes

I have to insert a field around a selected range to implement a functionality. As fileds are not supported in office-js I am using office open xml . I have implemented the code to insert a field before and after a selected text in a word document. OOXML corresponding to the field inserted looks like.

<w:r>
     <w:fldChar w:fldCharType='begin' />
</w:r>
<w:r>
    <w:instrText xml:space='preserve'>confidential</w:instrText>
</w:r>
<w:r>
      <w:fldChar w:fldCharType='end' />
</w:r>

After inserting is there anyway I can select the range where the fields are inserted.

For example in Word.ContentControl class we have select() method which will scroll to the selection, Also it has getRange() method.

Is there any way the same functionalities ( select() and getRange() ) can be done for a field inserted in a document

office-js word web-addin

1

1 Answers

0
votes

There is no good way to do this, aside from fetching the full OOXML of the paragraph where you inserted the Field and updating the full paragraph. Naturally this isn't a solution for any serious work. I've created a feature request for proper support of fields in the Word JS API