launching applications with javascript

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • David

    #1

    launching applications with javascript

    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="JavaS cript">
    function startPowerPoint (strFile)
    {
    var myApp = new ActiveXObject(" PowerPoint.Appl ication");
    if (myApp != null)
    {
    myApp.Visible = true;
    myApp.Presentat ions.Open(strFi le);
    }
    }
    </script>

    Then the link is:
    javascript:star tPowerPoint('ht tp://servername/PowerPoint_file s/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
  • Martin Honnen

    #2
    Re: launching applications with javascript



    David wrote:

    [color=blue]
    > The code I used to force the hyperlink to launch the application
    > rather than open the file in a browser is:
    >
    > <script language="JavaS cript">
    > function startPowerPoint (strFile)
    > {
    > var myApp = new ActiveXObject(" PowerPoint.Appl ication");
    > if (myApp != null)
    > {
    > myApp.Visible = true;
    > myApp.Presentat ions.Open(strFi le);
    > }
    > }
    > </script>
    >
    > Then the link is:
    > javascript:star tPowerPoint('ht tp://servername/PowerPoint_file s/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?[/color]

    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.Appl ication
    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.

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/

    Comment

    Working...