none
Best way to find a list of words in a word document and make a concordance?

    Question

  • I have a list of maybe 200 words; if any of those terms appear in a word document I'd like to highlight it (or add text effects).  Smart Tags would have made it easier--but they no longer provide a visual indicator. 

    After I change the visual display of the term, I'd like the user to be able to click or right click on the term and have a definition appear in an action pane. 

    I'm thinking that a loop that monitors the user's typing would be very slow.   So I guess I'll have a scan button--and leave it up to the user to click the button every so often. 

    What's the fastest way to parse through the doc and compare it to the list of terms?  Is there an object of words, like a collection or dictionary?  Something sorted and indexed like a concordance?

    What's the best way to make the term clickable or add it to the right click menu?  Once I find a special word I can just scan the doc for words that have the special highlight or effect and add other functionality that way.

    Is there an easier way to make the term part of a custom, clickable collection?  I'm going to look into smartArt or making the word into an object of some sort.  Maybe even a Visio object?  The problem there is that it may affect the readablity and flow of the text.

    Thanks,

    John

    Tuesday, July 19, 2011 10:10 PM

All replies

  • I have a list of maybe 200 words; if any of those terms appear in a word document I'd like to highlight it (or add text effects).  Smart Tags would have made it easier. 

    After I change the visual display of the term, I'd like the user to be able to click or right click on the term and have a definition appear in an action pane. 

    I'm thinking that a loop that monitors typing would be very slow.   So I guess I'll have a scan button.  What's the fastest way to parse through the doc and compare it to the list of terms?  Is there an object of words, like a collection or dictionary?  Something sorted like a concordance?

    What's the best way to make the term clickable or add it to the right click menu?  Once I find a special word I can just scan the doc for words that have the special highlight or effect and add other functionality that way.

    Thanks,

    John

     

     

    Tuesday, July 19, 2011 9:52 PM
  • I just found this:

    http://ucsdbiolit.codeplex.com/    ->  Word Add-in For Ontology Recognition

    It sounds like it may be exactly what I need.  It says it works with Word 2010...

     

    Wednesday, July 20, 2011 2:32 AM
  • I just found this:

    http://ucsdbiolit.codeplex.com/    ->  Word Add-in For Ontology Recognition

    It sounds like it may be exactly what I need.  It says it works with Word 2010...


    ...Just a quick update... too many issues with this.  For one thing it uses SmartTags which no longer work.  It's overkill for what I want to do, and it's popping up with so many 'strange' (build) errors that it's probably faster for me to start from scratch.

     

    Wednesday, July 20, 2011 2:32 AM
  • I just found this:

    http://ucsdbiolit.codeplex.com/    ->  Word Add-in For Ontology Recognition

    It sounds like it may be exactly what I need.  It says it works with Word 2010...

     


    Hi John, I'm not familiar with the product... If you find it's not what you're looking for, it might be best to ask this question first of the Word specialists. You'd probably want to use VSTO to implement it, but the parts of the object model that would be relevant won't be part of VSTO, they'll be part of Word. I can move this discussion to the Word for Developers forum, if you wish.
    Cindy Meister, VSTO/Word MVP
    Wednesday, July 20, 2011 10:05 AM
    Moderator
  • Hi Cindy,

    Thanks.  Actually, I made a separate post in the Word group.  With MS groups I never know when to crosspost or not.  Sorry if it's a no-no.

    ...Just a quick update... there are too many issues with this code.  For one thing it uses SmartTags which no longer work.  Also, it's overkill for what I want to do, and it's popping up with so many 'strange' (build) errors that it's probably faster for me to start from scratch.

     

     

    I guess the first thing I need to learn to do is add an action to the right click menu, even though I'm not using smart tags.  I guess the way to look at it is, I'm faking the old smart tag functionality using text effects.

     

    Other:

     

    Any good news as to VSTO being stabilized?   There's usually not a lot of info on 'current' versions, and by the time the info comes, VSTO changes and things get broken.  I would have never expected them to maim SmartTags like that.  Customers who want to upgrade to Office 2010 but have customization dollars invested in 2005 will be hesitant to do so. 

     

     ...it doesn’t make sense (to me).

     

     

    John

     

     

     

    Sunday, July 24, 2011 10:24 PM
  • Dear Jhon,

    You can try to remove the errors by  changing the .net framework.

    Hope this helps.

    Regards,


    Be happy.
    Monday, July 25, 2011 10:59 AM
  • Hi John

    I'm going to merge this question with the one you posted in the Word group, as that's the better place for an object-model question. As to the Smart Tags...

    This has nothing to do with VSTO. VSTO can only implement and extend what the Office applications make available. SmartTags were deprecated in Office 2010; I never have found out what the underlying reason was.


    Cindy Meister, VSTO/Word MVP
    Monday, July 25, 2011 12:21 PM
    Moderator
  • Hi John

    Word doesn't provide anything like this in its object model and it's difficult to think of a truly efficient method, especially if these are going to be longish documents.

    The standard, built-in and probably most efficent way would be to use Find/Replace in a loop - one loop for each term. And have Replace apply a special kind of formatting. This could be direct formatting (such as a color) or something that would let you manipulate all the "targets" at once, such as a style.

    As to the right-click, the Word Application has a WindowBeforeRightClick event you could use. That has an event argument that passes the Range (Selection) to the event so that you could check whether it's formatted using the target style. There's also a WindowBeforeDoubleClick event that could be used.

    There are other, possible variations, but they'll be much slower when scanning the document for terms and making them visible. For example, it's would be possible to place the terms into MacroButton field codes and associate the MacroButtons with a VBA macro. This would make the clickable, but locating and processing the terms would probably be quite a bit slower.


    Cindy Meister, VSTO/Word MVP
    Monday, July 25, 2011 12:31 PM
    Moderator
  • Hi John

    As to the right-click, the Word Application has a WindowBeforeRightClick event you could use. That has an event argument that passes the Range (Selection) to the event so that you could check whether it's formatted using the target style. There's also a WindowBeforeDoubleClick event that could be used.


    Cindy Meister, VSTO/Word MVP

    Hi Cindy,

    Thanks for the right click info, that sounds really useful. 

    Thanks for the styles info too; it looks like I can recreate the smartTags-like sqiggly line!   But if I need to add a "text code" of some sort, is there a way to turn off the spell check sqiggly line without adding it to the dictionary and filling it with exceptions?  Because I'll need my sqiggly line to have priority over the spell checker in some circumstances.

    For example, let's say the author wants to find a synonym for the word "lucky"  I'd like to be able to let them type xxluckyxx, scan the document looking for words enclosed by xx's and then replace that code with the custom style so that when they right click, they have the option of fetching a synonym.  Make sense?

    Regards,

    John


    Tuesday, July 26, 2011 1:38 AM
  • Hi John

    What you want to do makes sense, yes. I was going to say you can't use a squiggly line to format in Word, but I see they've added it at some point - the very botttom of the list. So I've just learned something new :-)

    You can mark ranges of text (which includes single characters or words) as "no proofing". And you can make this part of the style. If something's marked as "no proofing" then spell check should ignore it. NoProofing is a property of the Style object. In the UI these days it's equivalent to "don't check spelling or grammar" in the Language dialog box.


    Cindy Meister, VSTO/Word MVP
    Tuesday, July 26, 2011 6:54 AM
    Moderator
  • You can try to remove the errors by  changing the .net framework.

    Hi Mike,

    It was set to 3.5 and I tried to change it and got:

    "Attempted re-targeting of the project has been canceled.  The .Net Framework version you selected is not supported by this project type."

    But I think it likes 4.0 

    However, the first error I got was:

    Team Foundation Server http://vstfpg16:8080/tfs/pg16 does not exist or is not accessible at this time.   So, now it's a web service thing.

    Kind of off topic at this point, but there are many useful features in ucsdbiolit and if someone could update it, it would be a good learning tool for VSTO etc.

    

    Thursday, July 28, 2011 10:08 PM
  • Dear John,

    >>Team Foundation Server http://vstfpg16:8080/tfs/pg16 does not exist or is not accessible at this time.   So, now it's a web service thing.

    Kind of off topic at this point, but there are many useful features in ucsdbiolit and if someone could update it, it would be a good learning tool for VSTO etc.

    Has the problem been resolved? Yes, that error seems not related with VSTO technology, it is related with the TFS. Please see whether this article can help you:

    http://blogs.msdn.com/b/granth/archive/2008/06/26/troubleshooting-connections-to-tfs.aspx

    I am not very familiar with this tool:http://ucsdbiolit.codeplex.com/ , could you give me a brief introduction about what is the purpose of the tool?

    Hope this helps.


    Be happy.
    Monday, August 01, 2011 6:34 AM