launching applications with javascript

D

David

Hello. I've written a page for an intranet that gives the user the
option of launching a Word or PowerPoint document.

The code I used to force the hyperlink to launch the application
rather than open the file in a browser is:

<script language="JavaScript">
function startPowerPoint(strFile)
{
var myApp = new ActiveXObject("PowerPoint.Application");
if (myApp != null)
{
myApp.Visible = true;
myApp.Presentations.Open(strFile);
}
}
</script>

Then the link is:
javascript:startPowerPoint('http://servername/PowerPoint_files/template.PPT')

This works perfectly if PowerPoint is not running. However, if
PowerPoint is already open, it launches subsequent files underneath
the intranet page.

Is there a way to modify the script so that, whenever it launches a
PowerPoint document, it switches focus to that document?

Thanks,
David
 
M

Martin Honnen

David wrote:

The code I used to force the hyperlink to launch the application
rather than open the file in a browser is:

<script language="JavaScript">
function startPowerPoint(strFile)
{
var myApp = new ActiveXObject("PowerPoint.Application");
if (myApp != null)
{
myApp.Visible = true;
myApp.Presentations.Open(strFile);
}
}
</script>

Then the link is:
javascript:startPowerPoint('http://servername/PowerPoint_files/template.PPT')

This works perfectly if PowerPoint is not running. However, if
PowerPoint is already open, it launches subsequent files underneath
the intranet page.

Is there a way to modify the script so that, whenever it launches a
PowerPoint document, it switches focus to that document?

We rarely have people scripting PowerPoint here, if you have PowerPoint
then you should look into its documentation, it should document the
object model, the documentation is geared towards VBA but of course the
object model and the property and method names are the same when you use
JScript to script PowerPoint. Look up whether the PowerPoint.Application
object has a propery or method to bring it to the front. Looking into
the object model here I guess that
myApp.Activate();
brings the application window to the front but I haven't tested that.
I am sure people in a powerpoint group know more about that.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,821
Latest member
AleidaSchi

Latest Threads

Top