i want check spelling of a word using Win32::OLE::Const 'Microsoft Word';

i'm getting spelling suggestion for wrongly spelled words in EnglishUS language as default.
 but i want to change the default language as EnglishUK.
 or i want to set the spell check language as EnglishUK.

But i want in EnglishUS.

Please Help..

Thanks in advance.



This is my script for check spell in English US


use strict; use Win32::OLE; use Win32::OLE::Const 'Microsoft Word'; # Win32::OLE->Option(Warn => 0); my $word = Win32::OLE->new('Word.Application', 'Quit') or die; # $word-> {DisplayAlerts} = 0; # $word-> {WindowState} = 0; $word-> {Visible} = 0; my $doc = $word->Documents->Add(); my $range = $doc->{Content}; $range->{Text} = 'Analyser'; $range->InsertParagraphAfter(); my $paras = $doc->Paragraphs; foreach my $para (in $paras) { print ">> " , $para->Range->{Text}; my $text=$para->Range->{Text}; $para->Range->{LanguageID}=2057; my @errors=&spellcheck($word,$text); my @guesses; if($#errors==0) { foreach my $word(@errors) { my $guesses = $word->{'guesses'}; @guesses = @$guesses; } print "[@guesses]\n"; } else { print "[@guesses]\n"; } } <>; $doc-> Saved(0); $doc-> Close(0); $word-> Quit(); sub spellcheck { my $self = shift; my $text = shift; my $msword = $self; my @errors; while ($text =~ m/(\S+)\b/g) { my $offset = pos($text) - length($1) + 1; my $term = { term => $1, offset => $offset }; # If is correctly spelled proceed to the next word next if $msword->CheckSpelling($term -> {term}); # Otherwise look for spelling suggestions my $suggestions = $msword->GetSpellingSuggestions($term -> {te +rm},LanguageID => 2057); # No suggestions: if (!$suggestions || !$suggestions -> {Count}) { $term -> {type} = 'none'; $term -> {guesses} = []; push @errors, $term; # Some suggestions: } else { my @suggest; foreach (in $suggestions) { push @suggest, $_->{Name}; } $term -> {type} = 'guess'; $term -> {guesses} = \@suggest; push @errors, $term; } } return @errors; }

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.