#!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); # Words and language to search for my @words= ("quick","xxx"); my $language=$wd->{wdEnglishUS}; Win32::OLE->Option(Warn => 0); # Ignore OLE Errors # Get synonyms from MSWord for my $word (@words) { my $synonyms=$MSWord->SynonymInfo({Word => $word, LanguageID => $language}); my $OLEerror = Win32::OLE->LastError(); unless ($OLEerror) { if ($synonyms->Found) { foreach (@{ $synonyms->SynonymList(1) }) { print "$word: $_.\n" }; } else { print "$word: Do not have any synonyms.\n"; } } else { print "OLE Error: $OLEerror\n"; } } Win32::OLE->Option(Warn => 1); # Reset to default OLE Error Handling