none
Issue with the development of Microsoft Office 2013 RRS feed

  • Question

  • Our team is working on a plug-on to Microsoft Word for Office 2013 and earlier.

    We have faced problems of saving Word formatting when trying to capture the formatting contained in the text of a document within our plug-in's text box. When we capture the piece of text, it contains a lot of hidden elements which Microsoft Office uses for formatting the piece of text. Whenever our plug-in captures the text we cannot grab all that hidden elements as they are stored in the core of Microsoft Office which is closed for outside developers.

    Thus, when the text is picked up by our plug-in's text box, we cannot preserve the initial formatting which the text had (e.g. if it was a phrase "Hello to you sir" the bold italicised formatting disappears and the result which we get in our plug-in's text box is "Hello to you sir" (i.e., we are able to see the text but we lose the bold, italics formatting).

    Could you advise us if there is a way to capture all the formatting which is stored in the core in order to have the same settings for the whole phrase formatting when we are reviewing the text from the document in our plug-in's text box?

    Many thanks in advance

    Tuesday, September 26, 2017 1:47 PM

All replies

  • Hi N Fonu,

    What is the plug-on? Is it an VSTO add-in?

    I think office does not provide any property/method to get all format of a text string.

    What’s the text box? Could Selection.PasteAndFormat work for you?

    Best Regards,

    Terry


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, September 27, 2017 10:54 AM
  • Anything that reads a text string captures only the text, not its formatting. Unless your textbox supports rich text, even if you were to copy the formatted content from Word and paste it into your textbox, the formatting would be lost.

    Cheers
    Paul Edstein
    [MS MVP - Word]

    Thursday, September 28, 2017 1:19 AM
  • Thanks, Paul. Just to clarify, would the formatting still be lost if the textbox supports rich text?
    Thursday, September 28, 2017 11:31 AM
  • That depends on how you add the content to it. If it allows you to copy/paste or use Word's FormattedText method (unlikely), the formatting can be preserved.

    Cheers
    Paul Edstein
    [MS MVP - Word]

    Thursday, September 28, 2017 12:35 PM