[英]How to change MS Word spelling check language through Ole in Delphi?
I utilize Microsoft Office 2007 Standard Edition in Delphi 2009 through Ole automation to check spelling. 我通过Ole自动化利用Delphi 2009中的Microsoft Office 2007 Standard Edition检查拼写。 Checking works for my system language (Russian).
检查是否可以使用我的系统语言(俄语)。 However, I can't find a way to change it to English.
但是,我找不到将其更改为英语的方法。
That's how I create my spell checking object. 这就是我创建拼写检查对象的方式。
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;
This is the method that actually checks. 这是实际检查的方法。
function CWordSpellChecker.IsCorrect(_Text: String): Boolean;
begin
result := False;
if FActive then
if MsWordApp.CheckSpelling(_Text) then
result := True;
end;
Could you please tell me what I need to add to my code to change the language to English? 您能告诉我我需要添加到代码中以将语言更改为英语吗?
The following code seems to work for me, using D7 and Word 2007 (I don't have a later Delphi version on this machine). 以下代码似乎对我有效,使用D7和Word 2007(此计算机上没有更高的Delphi版本)。 My default Word language is English UK .
我的默认文字语言是英国英语。
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;
. 。 This code pops up the spelling correction dialog on
colour
and offers to "correct" it to the US spelling color
. 该代码会弹出
colour
的拼写校正对话框,并提供将其“校正”为美国拼写color
。
Various flavours of English are listed in the Word import unit Word2000.Pas, namely 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.