none
VTSO | Microsoft Word | Ranges | Cut & Paste RRS feed

  • Question

  • Hi,

    I'd like to write an MS Word VTSO add-in that conditionally 'hides' selected range of the document. The selected range could be a drag selection of text, images, lines, etc associated with a bookmark. On the action of a button I'd then like to hide the range and then, later, put it back. 

    It does seem possible to cut the range to the clipboard, save it away as RTF, and then put it back but this does not always work. If you select a shape - a line for example - then you can't save it in RTF, you can only save it as "Art::GVML ClipFormat" but then you can't paste it back into a range - you just get notification of the paste failing and no inner exception to explain why!

    These objects are also interesting in that in Word if you select a line, cut it and paste it back, then it does not go back where it was. It as thought the cut & paste does not preserve the anchor information.

    Any suggestion on how to hide / restore ranges would be appreciated!

    Martin

    Thursday, August 9, 2018 1:34 PM

All replies

  • What does this question have to do with the VSTO technology? It sounds like it's completely Word-oriented...

    Anyway, the only possibility, I believe, would be to get Seleciton.Range.WordOpenXML and save that somewhere. It can later be re-inserted using Range.InsertXML

    What WordOpenXML gives you is the Word Open XML package in the OPC flat-file format (as one long string instead of multiple xml files in a zip package).


    Cindy Meister, Office Developer/Word MVP, <a href="http://blogs.msmvps.com/wordmeister"> my blog</a>

    Friday, August 10, 2018 12:19 PM
    Moderator