none
Marking/Highlighting Text in Word RRS feed

  • Question

  • Hi there,

    I’m developing an Add-In for Word 2013 with C#.

    I have to mark text parts without changing the content of the document. The file should remain useable so that another user without the Add-In can work with it and will not see the marks. The files that will be used with the add-in can have more than 200 pages.

    I tried some ways to do this but none worked for me. Now I’m hoping that someone has any ideas or tips for me.

    First I tried to find a way to render some kind of own layer/background behind the text. I added some WinForms but they stayed in the front, were selectable and moveable.

    Another idea was to look for any highlighting options. Unfortunately I didn’t found a way to highlight text without changing the formatting. I found the HighlightColor and the Shading-Color options and got the idea to store the original formatting and restore it before saving. But the storing takes several minutes for 200 pages.

    My third idea was to use the Find.HitHighlight-function. I don’t have to store anything in that way but I only found a way to mark one block at once but I need a way to mark several Blocks. Also I would like to use different color.

    I hope anybody has an idea for my problem.

    Many thanks

       Dresaan

    Tuesday, April 15, 2014 2:36 PM

Answers

  • Hi Dresaan

    I don't think you're going to be able to do what you envision - Word doesn't provide support for "layers". It would be possible to use Drawing objects (a rectangle) in a similar way to what you apparently tried with Windows Forms controls and place them "behind the text". They wouldn't be as easily moved and require less processing time.

    Other than that, the only thing that occurs to me would be to place the text into Content Controls. In Word 2013 you can assign different colors to them and they'll show up when the mouse goes over them. On saving your code could set the "Show as" to "None" so that the content controls aren't visible. (This would be the ContentControl.Appearance property that accepts a value from this enum http://msdn.microsoft.com/de-de/library/office/jj231358(v=office.15).aspx)


    Cindy Meister, VSTO/Word MVP, my blog

    Tuesday, April 15, 2014 4:55 PM
    Moderator

All replies

  • Hi Dresaan

    I don't think you're going to be able to do what you envision - Word doesn't provide support for "layers". It would be possible to use Drawing objects (a rectangle) in a similar way to what you apparently tried with Windows Forms controls and place them "behind the text". They wouldn't be as easily moved and require less processing time.

    Other than that, the only thing that occurs to me would be to place the text into Content Controls. In Word 2013 you can assign different colors to them and they'll show up when the mouse goes over them. On saving your code could set the "Show as" to "None" so that the content controls aren't visible. (This would be the ContentControl.Appearance property that accepts a value from this enum http://msdn.microsoft.com/de-de/library/office/jj231358(v=office.15).aspx)


    Cindy Meister, VSTO/Word MVP, my blog

    Tuesday, April 15, 2014 4:55 PM
    Moderator
  • Thank you for the information and tips. I'll test that and hope that it works
    Wednesday, April 16, 2014 1:34 PM