hi,
i am able to display ms-word spell check utility on my form by minimizing
the word document. but the spell check utilty appears in the background. it
appears as a modal dialog.
Q1. how do i make it appear on the foreground.
Q2. it has some painting problems. when i move the spell check window around
my form window doesnt paint properly.
Q3. i used the following approach to display ms-word spell checker in my
app. the reason is that i want it to work with atleast the recent versions
of word (2002 and 2003). is there a better approach than this?
I dont want to add a reference to my app because that reference will point
to only one version of office. and i want my app to work with 2002 and 2003.
i dont know what version my clients may have.
i create interfaces like so
[Guid("0002096B-0000-0000-C000-000000000046"),
InterfaceType(ComInterfaceType.InterfaceIsIDispatc h)]
interface _Document
{
[DispId(0x0000002a)]
_Window ActiveWindow
{
get;
}
[DispId(0x00000451)]
void Close(object saveChanges, object originalFormat, object
routeDocument);
[DispId(0x00000084)]
void CheckSpelling(object CustomDictionary,object IgnoreUppercase,object
AlwaysSuggest,object CustomDictionary2,object CustomDictionary3,object
CustomDictionary4,object CustomDictionary5,object CustomDictionary6,object
CustomDictionary7,object CustomDictionary8, object CustomDictionary9, object
CustomDictionary10);
}
similarly i have _Application interface and _Documents interfaces and so on
...
and then i simply call this
public static string CheckSpelling(string text)
{
Type type = Type.GetTypeFromProgID("Word.Application");
object wordApplication = Activator.CreateInstance(type);
app = (_Application)wordApplication;
_Document doc;
_Documents docs = (_Documents)app.Documents;
doc = docs.Add(Missing.Value, Missing.Value, Missing.Value, true);
doc.ActiveWindow.WindowState = WdWindowState.wdWindowStateMinimize;
app.Selection.Text = text;
doc.CheckSpelling(Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value);
doc.ActiveWindow.Selection.WholeStory();
newText = doc.ActiveWindow.Selection.Text;
app.Visible = false;
doc.Close(false, Missing.Value, Missing.Value);
doc = null;
}
thnx.