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..
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 ??
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 ??