Re: Accessing the Thesaurus in Word 2003 Programmitically in C#



Hi =?Utf-8?B?QmxpbmRDb2Rlcg==?=,

I hope sombody can answe this question...... I've been bangin my head tryin
gto fdind som eosort of sample application that is directly re ferenceing hte
com librbrary for access to the Office 2003 thesaurus results when looking up
a word pregrammicially in a C# application. This SHOULD be simple and as my
Com interopability skills are LOW and I can SEE the results in the VIsual
Studio Debugger as a System.Object returned with Dimestion s (This system.
Object has the Sysnonyms lksited for a word I lookup in the thesaurus.
However, When I call the method: " doc1.Words[1].SynonymInfo.MeaningList" in
C# Code the returned object is System.object I believe HOW CAN I GET THESE
VAULES IN A STRING ARRAY? Do I hafta Cast to somthing from whithin the CVom
oBjects Librbay to get the strings? Can I enumerate the results from System
Object? or need I convert from SYstem.object to System.Object[] ? Sombody
help me.

If you read the Help carefully, you'll see that that data type of the returned
array is a VARIANT. Since the .NET Framework doesn't support this data type, it
converts it to System.Object. This means you have to cast the returned object to
an array. Here's an example

wd.SynonymInfo synInfo = wdDoc.Words[1].SynonymInfo;
object meanings = synInfo.MeaningList;
Array meaningList = (Array) meanings;
MessageBox.Show(String.Format("The term '{0}' has {1} meanings.", testTerm,
meaningList.Length.ToString()));
string allMeanings = "";
foreach (string meaning in meaningList)
{
allMeanings += meaning + "\n";
}
MessageBox.Show(allMeanings);

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :-)

.



Relevant Pages

  • Re: Javascript Quote Problems
    ... It produces an unterminated string js ... my failed attempt to use image variables (gives unterminated ... In fact since the array inside the array have elements that have different ... meanings an object might be more appropriate:- ...
    (microsoft.public.scripting.jscript)
  • Re: Constant strings
    ... different meanings. ... In the one case, the array ... array that are const. ... different from an array of const int, the are intensionally different, ...
    (comp.lang.c)
  • Re: how to convert decimal number into base 64 format
    ... That question could have two meanings. ... base64 is a common encoding. ... You first have to convert to a byte array. ...
    (comp.lang.java.programmer)
  • Re: Determine if array is empty
    ... de-mystify them by describing some of the under the hood workings. ... When a script creates and populates an array, ... (hence we may be thinking of different meanings). ...
    (microsoft.public.scripting.vbscript)
  • Re: Object to binary[] from COM in .NET using C#
    ... >I can't cast into an array, of course, ... What's the actual type of the returned object ... Mattias Sjögren [MVP] mattias @ mvps.org ...
    (microsoft.public.dotnet.languages.csharp)