Draw my own squigglies on Word document...

Is there anyway in VSTO that I can draw my own squigglies (like the red squiggly for spelling mistakes, and the green squiggly for grammar check) on a Word document If I want to underline a sentence with my own colored squiggly, can this be done Can I call directly into COM to do this Or is this impossible

Bottom line is I'd like to apply my own custom non-printable formatting to certain parts of a Word doc (like the squigglies or the dots that appear under SmartTags) -- is there *any* way to do this from a VSTO solution (even if the code is ugly).

Thanks in advance...



Answer this question

Draw my own squigglies on Word document...

  • error maker

    You could keep track of the original underline and underline color in a hashtable wherethe keys would be the ranges you made changes to and the values would be point-like structures with x corresponding to underline and y corresponding to the original underline color. When you want restore the original formatting you'd just loop over the keys in the hashtable and apply original formatting.

    It's an idea.


  • Brian Johnson MS

    Lynn,

    there is no obvious way to arbitrarily apply underlining squiggles to text in a document. As you noted, Smart Tags allow you to underline text that is significant in some way. I have written a number of smart tag articles, and there is grreat ref documentation to help you. I recommend you create a smart tag to do what you want. It's what it was actually designed to do! (just what you are want to do)

    You can also change the underline color (get the smart tag development toolkit).

    find it all here:

    http://msdn.microsoft.com/office/understanding/smarttags/

     

    John



  • Laquesis

    Thanks for the suggestion, but that solution will not work given my requirements. If the content block already contains some underlined text, then this code:

    Range.Font.Underline = Word.WdUnderline.wdUnderlineWavy
    Range.Font.UnderlineColor = Word.WdColor.wdColorBlue

    ...will blast over the original underline. It is vital that the content block stay formatted exactly as it original was -- thus my desire to introduce formatting that is visual only. 


  • Aaron Schurg

    John, thanks for the reply. When you say "there is no obvious way" does that mean it *cannot* be done, or it is not obvious how to do it -- I'm not afraid to venture into non-VSTO code to accomplish this. I have looked extensively into SmartTags and (without going into the details) they aren't really what I want.

    Basically, I'm programmatically inserting blocks of content (that can contain rich text, tables, images, etc) into a document and wrapping the newly inserted text in a VSTO bookmark. Depending on how the content was injected, I then need to apply some sort of visual formatting to the inserted content. However, I only want this formatting to be visual (not printed) and I don't want it to blast any of the formatting the content already has in place. Thus, I can't just apply typical formatting (i.e., an underline style,  background color, etc), as the injected content block might already be using this formatting. Hence my desire to use some highlight mechanism like the ones used by Word's spell checker (red squigglies), smart tags (red dots), or comments (the yellow background).

    I know the VSTO Bookmark will surround the content block with gray braces, but I need additional formatting so the document has a "layered" look -- i.e., all content blocks inserted from source A have visual formatting of type A, all content blocks inserted from source B have visual formatting of type B, etc. If I could change the color of the gray braces on the bookmark control then that would help accomplish what I want.

    So if there's *any* way to do something like this (even if it's ugly), please let me know.

    Thanks!


  • Vinit Tyagi

    If you can get reference to range or selection objects, the following should work for you:

    Range.Font.Underline = Word.WdUnderline.wdUnderlineWavy

    Range.Font.UnderlineColor = Word.WdColor.wdColorBlue

    hope this helps

     


  • hotfoot982

    Have you tried the solution I suggested earlier. It's simple and it works straight from VSTO without smart tags. You just need to find the range you'd like to hilite.

    I'm not sure about printing, you might have to remove underline and underline color before printing.

     

    Range.Font.Underline = Word.WdUnderline.wdUnderlineWavy

    Range.Font.UnderlineColor = Word.WdColor.wdColorBlue


  • Draw my own squigglies on Word document...