views:

48

answers:

1

I wan't to build a word 2007 add-in that allows users to:

  • Hilight pargraphs etc. of text in a word document.
  • Click a toolbar button or select an option from a right-click menu to "mark" the text as being some type of data (there will be 3 of 4 different types of data)
  • Also, the ability to select some text and and unmark it (this would automatically expand the selection to cover the full piece of marked up text).

The people marking up the documents will be non-technical, so we want to keep it very simple.

I have been investigating some different ways I could implement this including:

  1. Bookmarks - naming bookmarks i.e. each time a type is hilighted and "marked" the app would add a bookmark with the type name followed by say a number i.e. my_custom_type-1, my_custom_type-2 etc.
  2. Hidden text - sticking hidden text into the document (where font is set to hidden) - so we could basically surround a selected paragraph with some hidden text i.e. {my_custom_type} ... {/my_custom_type}, some other type of text with {another_custom_type} ... {/another_custom_type} etc.
  3. Named styles - having styles for each of the types of data, and just using the Range.set_Style(...) method to set the style.

So far I've tried option 3 - which seems to be working well to mark up text, but not so well when I try to umark text (it doesn't work, if I for example try setting the type back to "normal" using the set_Style method).

Are these the only ways for marking up text in a word document programmatically (without physically displaying additional content in the document) - and can anyone recommend one approach over another, especially when we need to then parse all the data out that's been marked up.

+1  A: 

You might want to try using highlighting (as in the yellow-highlighter icon on the toolbar). There are several different colours available - certainly enough for your needs. Since highlighting is in addition to all the other formatting, and rarely actually part of the "real" formatting of the document, it seems like a good choice. It'd be really easy to turn off, since you don't need to worry about splatting the other formatting of the text. You also have a ready-made UI :-)

Gary McGill
Yeah, I might give that a try... I'll have to check and see if the documents don't already contain any highlighting though - that could cause issues.
Bittercoder