繁体   English   中英

如何通过Delphi中的Ole更改MS Word拼写检查语言?

[英]How to change MS Word spelling check language through Ole in Delphi?

我通过Ole自动化利用Delphi 2009中的Microsoft Office 2007 Standard Edition检查拼写。 检查是否可以使用我的系统语言(俄语)。 但是,我找不到将其更改为英语的方法。

这就是我创建拼写检查对象的方式。

constructor CWordSpellChecker.Create;
begin
     try
          MsWordApp := CreateOleObject('Word.Application'); //MsWordApp is OleVariant
          MsWordApp.Options.IgnoreMixedDigits := False;
          MsWordApp.Visible := False;
          FActive := true;
          MsWordApp.Documents.Add;
     except
          on E: Exception do begin
               MessageDlg('Cannot Connect to MS Word', mtError, [mbOk], 0);
               FActive := false;
          end;
     end;
end;

这是实际检查的方法。

function CWordSpellChecker.IsCorrect(_Text: String): Boolean;
begin
     result := False;

     if FActive then
          if MsWordApp.CheckSpelling(_Text) then
               result := True;
end;

您能告诉我我需要添加到代码中以将语言更改为英语吗?

以下代码似乎对我有效,使用D7和Word 2007(此计算机上没有更高的Delphi版本)。 我的默认文字语言是英国英语。

  MSWord.Selection.TypeText('The colour is blue');  //  "colour" is the correct spelling in UK English, but not
                                                    //  US English

  MSWord.ActiveDocument.AttachedTemplate.LanguageID := wdEnglishUS;
  MSWord.ActiveDocument.AttachedTemplate.NoProofing := False;
  MSWord.Selection.LanguageID := wdEnglishUS;
  MSWord.ActiveDocument.CheckSpelling;

该代码会弹出colour的拼写校正对话框,并提供将其“校正”为美国拼写color

Word导入单元Word2000.Pas中列出了各种英语风味,即

  wdEnglishAUS = $00000C09;
  wdEnglishBelize = $00002809;
  wdEnglishCanadian = $00001009;
  wdEnglishCaribbean = $00002409;
  wdEnglishIreland = $00001809;
  wdEnglishJamaica = $00002009;
  wdEnglishNewZealand = $00001409;
  wdEnglishPhilippines = $00003409;
  wdEnglishSouthAfrica = $00001C09;
  wdEnglishTrinidad = $00002C09;
  wdEnglishUK = $00000809;
  wdEnglishUS = $00000409;
  wdEnglishZimbabwe = $00003009;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM