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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I have a problem with returning foc

Status
Not open for further replies.

drkestrel

MIS
Sep 25, 2000
439
GB
I have a problem with returning focus to an IE window which creates a Word ActiveX object to generate and pritng a document.

The code snippet is..
Code:
var objWordApp = new ActiveXObject("Word.Application");
var objWordDoc = objWordApp.Documents.Add(sTemplateLoc);
objWordDoc.Windows(1).Selection.TypeText("Type Something");

var dlgPrint = objWordApp.Dialogs(88);        //88 is the File Print dialog
dlgPrint.show(0);

delayedQuit();       //delayedQuit is a function that recursively 
                     //call itself using setTimeOut() function, until 
                     //the background print queue has dropped to 0, 
                     //before it 
                     // 1)waits an extra 400 miliseconds and 
                     // 2)closes Word

window.focus();    //return focus to IE

The above works most of the time, but

1) When running on IE6SP1 on Win2K SP2 sometimes, when Outlook Express is opened also, the focus is returned to Outlook Express instead of IE. (This could happen even if the user does NOT switch to other applications whilst the word document is being generated and printed)

2) When running IE 6SP1 through a Window Terminal Services Client, the focus is returned to:
2.1) The application that Last has the focus before IE is started where no applications was started after IE or
2.2) The last application that was started after IE was invoked, where applications were started after IE was invoked.
(These applications could be anything, from a command prompt, hyper-terminal, Excel to outlook or outlook express)

Anyone has any idea how to resolve this problem ??
 
Would you not get the IE ID first, and the use that in window.focus(ID) ? If the solution is here, let us know it was helpful so others can benefit from it as too
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top