Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ActiveX Object and MS Word

Status
Not open for further replies.

Terwin

Programmer
May 23, 2002
51
US
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();
}
 
perhaps after making the Word object, make it visible?

Word = new ActiveXObject(&quot;Word.Application&quot;);
Word.visible = true;



=========================================================
while (!succeed) try();
-jeff
 
I actually just added that - and it may have to do. While setting visible = true results in an open document on the task bar, it does not necessarily ensure focus on that document.

Thanks for the response.
T
 
A ridiculous hack that I know works on PhotoShop.

Word.visible = true
Word.visible = false
Word.visible = true

There has to be a better way, maybe someone will enlighten us.
 
That IS ridiculous - but classic JScript :)

Thanks a lot.

When ridiculous hacks exist, who needs enlightenment.

T
 
I looked for some type of method but found nothing. Just FYI I use it to return focus to the app.

function one() {
Word = new ActiveXObject(&quot;Word.Application&quot;)
Word.visible = true
}

// then after it's lost focus

function two() {
Word.visible = false
Word.visible = true
}

I think for info on word you can start digging here


you have to use IE on that link to get the right menu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top