I have a javascript function that invokes the MS Word spell checker on a large web form. The issue I am running up against is that for some users, the spell check window appears behind all other open applications. I have very little information on the Word DOM and basic window manipulation using ActiveX objects. How can I ensure that the spell check window gets focus when it is invoked? Also, does anyone know some good places to find information on the Word DOM and ActiveX scripting? I haven't been able to locate the right information on the MSDN site.
Code is below, thank you.
Terwin
function beginSpellCheck() {
var Word, Doc;
var Uncorrected = "";
var Corrected = "";
var wdDialogToolsSpellingAndGrammar = 828;
var wdDoNotSaveChanges = 0;
var lmax = document.mainform.elements.length;
var lCounter;
var element;
Word = new ActiveXObject("Word.Application"
Doc = Word.Documents.Add();
for (lCounter=0; lCounter < lmax; lCounter++){
if ((mainform.elements[lCounter].type == 'textarea')
|| (mainform.elements[lCounter].type == 'text')) {
Uncorrected = mainform.elements[lCounter].value;
if (Uncorrected != undefined) {
Word.Selection.Text = Uncorrected;
Word.Dialogs(wdDialogToolsSpellingAndGrammar).Show();
if (Word.Selection.Text.length != 1)
Corrected = Word.Selection.Text;
else
Corrected = Uncorrected;
mainform.elements[lCounter].value = Corrected;
}
}
}
Doc.Close(wdDoNotSaveChanges);
Word.Quit();
}
Code is below, thank you.
Terwin
function beginSpellCheck() {
var Word, Doc;
var Uncorrected = "";
var Corrected = "";
var wdDialogToolsSpellingAndGrammar = 828;
var wdDoNotSaveChanges = 0;
var lmax = document.mainform.elements.length;
var lCounter;
var element;
Word = new ActiveXObject("Word.Application"
Doc = Word.Documents.Add();
for (lCounter=0; lCounter < lmax; lCounter++){
if ((mainform.elements[lCounter].type == 'textarea')
|| (mainform.elements[lCounter].type == 'text')) {
Uncorrected = mainform.elements[lCounter].value;
if (Uncorrected != undefined) {
Word.Selection.Text = Uncorrected;
Word.Dialogs(wdDialogToolsSpellingAndGrammar).Show();
if (Word.Selection.Text.length != 1)
Corrected = Word.Selection.Text;
else
Corrected = Uncorrected;
mainform.elements[lCounter].value = Corrected;
}
}
}
Doc.Close(wdDoNotSaveChanges);
Word.Quit();
}