in reply to Re: Problem using Win32::OLE with MS Word
in thread Problem using Win32::OLE with MS Word

I tried your solution and it worked beautifully but I get another puzzling error if Iadd the word "pieces" to the array. eg.

my @words=("quick","xxx","pieces");


To hopefully get more of an indication of what the problem is, I uncommented your line:

Win32::OLE->Option(Warn => 0); # Ignore OLE Errors

The error I get when I run the script is this:

quick: rapid quick: fast quick: speedy quick: swift quick: nippy xxx: Do not have any synonyms. OLE exception from "Microsoft Word": One of the values passed to this method or property is out of range. Win32::OLE(0.1403) error 0x800a16d3 in METHOD/PROPERTYGET "SynonymList" at C:\adam2.pl line 22 Can't use an undefined value as an ARRAY reference at C:\adam2.pl line + 26.


The thing is if I use the Thesaurus in MS Word directly on the word "pieces" it does return one entry, that being "piece".

Any idea why then the script reports that value as being out of range?

Replies are listed 'Best First'.
Re^3: Problem using Win32::OLE with MS Word
by adambrad (Initiate) on Nov 12, 2005 at 12:23 UTC
    Actually, looking at this more closely:

    >>The thing is if I use the Thesaurus in MS Word
    >>directly on the word "pieces" it does return one
    >>entry, that being "piece".

    ...that is not true. In fact, the Thesaurus returns "piece" and suggests this as a related word(ie. Replace with Related Word) and not as a synonym (ie. Replace with Synonym).

    So in this case there is no suggested synonym but how would I go about coding for that (I don't want related words - just a list of matching synonyms returned).

    Thanks, Adam
      Solved. Just had to replace this:
      if ($synonyms->Found)

      ....with this:
      if (($synonyms->Found) && ($synonyms->SynonymList(1)))