in reply to How to get spelling suggestions in EnglishUK language as default in Win32::OLE

When it comes to remote controlling Word, a useful tool is its macro recorder. Record the change you want to make, look at the macro, then Perlify it.

  • Comment on Re: How to get spelling suggestions in EnglishUK language as default in Win32::OLE

Replies are listed 'Best First'.
Re^2: How to get spelling suggestions in EnglishUK language as default in Win32::OLE
by Anonymous Monk on Feb 22, 2010 at 04:25 UTC
    Thanks for your quick reply. But i want as perl code.
      First you need to know what to do. That's what the macro recorder tells you. Then you can code it in Perl. If you have problems with that, come back with your new problem.
        I tried in word macro and then finally i done in perl intself. Thanks for the quick reply.
        $MSWord = Win32::OLE->new('Word.Application', 'Quit') or die "Coul +d not load MS Word\n"; $wd=Win32::OLE::Const->Load($MSWord); $doc = $MSWord->Documents->Add(); my $range = $doc->{Content}; $range->{LanguageID}=2057; $range->{Text} ="$word"; eval {$range->InsertParagraphAfter();}; if($@) { print "Error occur for word :: $word in English UK Function In +sertParagraphAfter\n"; open er,"$0_Error_Log.txt"; print er "Error occur for word :: $word in English UK Function + InsertParagraphAfter\n"; close er; return; } my $suggestions = $range->GetSpellingSuggestions(); my $result_UK; my @suggestions_UK; my $offset = pos($word) - length($word) + 1; my $term = { term => $word, offset => $offset }; if ($suggestions || $suggestions->{Count}) { my @suggest; my @errors; foreach (in $suggestions) { push @suggest, $_->{Name}; } $term -> {type} = 'guess'; $term -> {guesses} = \@suggest; push @errors, $term; foreach my $word(@errors) { my $guesses = $word->{'guesses'}; @suggestions_UK = @$guesses; } } $doc->{Saved} = 1; $doc->Close(); $MSWord->Quit();
        Please can you send the macro code. I tried macro with word.but i can check the word is present in EnglishUK dictionary. but i am not able to get the spell suggestion.
      The easy way: 1) get macro 2) translate to perl