adam2005 has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem using Win32::OLE with MS Word
by Trix606 (Monk) on Nov 11, 2005 at 04:06 UTC | |
by adambrad (Initiate) on Nov 12, 2005 at 11:59 UTC | |
by adambrad (Initiate) on Nov 12, 2005 at 12:23 UTC | |
by Anonymous Monk on Nov 14, 2005 at 10:57 UTC | |
|
Re: Problem using Win32::OLE with MS Word
by jplindstrom (Monsignor) on Nov 11, 2005 at 00:10 UTC | |
|
Re: Problem using Win32::OLE with MS Word
by Discipulus (Canon) on Nov 11, 2005 at 09:40 UTC |