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!

question about opening Word doc in javascript

Status
Not open for further replies.

aozm

Programmer
Jan 4, 2007
1
US
am using the following to open a Word document on the client side:

function launchWord(strFile)
{
var oWord = new ActiveXObject("Word.Application");
if (oWord != null)
{
oWord.Visible = true;
oWord.Documents.Open(strFile);
}
}

This works fine when I have strFile set to something like "C:\\test.doc" But when I try to set it to the root of the web page with just "\test.doc" or in the same folder that the asp page is in with "test.doc", it says file not found. How do I set the location to be the same folder where the asp page is in?

Also, how do I set focus to the Word document? Right now it is coming up behind the asp page.

Thanks!
 
[1]
>But when I try to set it to the root of the web page with just "\test.doc" or in the same folder that the asp page is in with "test.doc", it says file not found.
http protocol is not supported by open method of word application, I don't think. To serve word document stored on the server to client, use server-side script. (Ask the appropriate forum according to the technology used.)
[2]
Also, how do I set focus to the Word document?
Add this line.
[tt]oWord.Active();[/tt]
But the effectiveness is not 100%, it has to negotiate with the concrete setting of the os environment and the latter takes priority.
 
Correction
Sorry, upon reading, it was "Activate" that I meant!
[tt] oWord.Activ[red]ate[/red]();[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top