In the above example $word="quick" and the script works fine; however, if I were to use a word for which there are no synonyms in MS Word (eg. $word="xxx"), then when the script runs it returns with this error:#!perl -w # Uses use strict; use Win32::OLE; use Win32::OLE::Const; # Create MSWord object and load constants my $MSWord = Win32::OLE->new('Word.Application', 'Quit') or die "Could not load MS Word\n"; my $wd=Win32::OLE::Const->Load($MSWord); # Word and language to search for my $word="quick"; my $language=$wd->{wdEnglishUS}; # Get synonyms from MSWord my $synonyms=$MSWord->SynonymInfo( {Word => $word, LanguageID => $language})->SynonymList(1); # Print them out... foreach (@{ $synonyms }) { print $_."\n" };
I'm not sure how to handle such an error. Ideally, I would like the script to just print out "No synonym suggestions". Can anyone help?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:\syn.pl line 18
In reply to Problem using Win32::OLE with MS Word by adam2005
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |