맞춤법 검사를 사용하려는 사내 Windows 양식 응용 프로그램이 있습니다. Office 2007이 설치되어있어 모두 거기에 문제가 없어야하지만 문제가 발생합니다. 이것은 완전히 작동합니다.Windows 양식 응용 프로그램에서 Word 맞춤법 검사 구현
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Word = Microsoft.Office.Interop.Word;
using System.Reflection;
namespace Refraction.Spelling
{
public static class SpellCheckers
{
public static string CheckSpelling(string text)
{
Word.Application app = new Word.Application();
object nullobj = Missing.Value;
object template = Missing.Value;
object newTemplate = Missing.Value;
object documentType = Missing.Value;
object visible = true;
object optional = Missing.Value;
object savechanges = false;
Word._Document doc = app.Documents.Add(ref template, ref newTemplate, ref documentType, ref visible);
doc.Words.First.InsertBefore(text);
Word.ProofreadingErrors errors = doc.SpellingErrors;
var ecount = errors.Count;
doc.CheckSpelling(ref optional, ref optional, ref optional, ref optional,
ref optional, ref optional, ref optional, ref optional, ref optional,
ref optional, ref optional, ref optional);
object first = 0;
object last = doc.Characters.Count - 1;
var results = doc.Range(ref first, ref last).Text;
doc.Close(ref savechanges, ref nullobj, ref nullobj);
app.Quit(ref savechanges, ref nullobj, ref nullobj);
return results;
}
}
}
내가 지금처럼 이것을 사용 :
memDirectionsToAddress.Text = SpellCheckers.CheckSpelling(memDirectionsToAddress.Text);
지금이 성공적으로 말씀에서 맞춤법 검사 대화 상자를 팝업 및 맞춤법이 틀린 단어
을 감지하지만 내가 얻을 수 없다 여기
또한 워드 문서의이 "쉘"은 수정 된 텍스트로 열어 둡니다. 그걸 보여주지 않거나 적어도 없어지지는 않는가?
두 가지 :
- 첫째, "쉘이"그것을 깜박 매번을 닫습니다하지만. 그 어떤 해결책을 ?
- 둘째, 맞춤법 검사 대화 상자에서 이 TOP에 나타나지 않습니다. 무엇을 으로 수정하면됩니까?
감사
기타 질문 :이 기능을 고정시키지 않는 이유가 있습니까? –
정적으로 만들지 않으면 특정 문서 및/또는 응용 프로그램이라는 단어에 대한 참조를 유지할 수 있습니다. 그러면 새로운 앱이나 문서의 초기 비용을 피할 수 있습니다. (Visible 속성이나 앱을 가지고 놀고 항상 새로운 앱을 시작하면 문서를 열어도 보이지 않게 유지할 수 있습니다.) –
만약 내가'app.Close()'를하지 않으면 Word의 껍데기가 끝나면 끝납니다. –