Detect ActiveX

Discussion in 'ASP .Net' started by David C, Nov 11, 2008.

  1. David C

    David C Guest

    I have an ASP.Net page that displays documents as hyperlinks from a network
    folder (intranet application). I also have a column that contains a
    hyperlink to open the document in Microsoft Word. All works fine unless
    someone has ActiveX disabled on their browser. Is there any way I can
    detect that so I can give them a warning?

    The script for opening a Word document is below. Thanks.

    -David

    <script language="javascript" type="text/javascript">

    function openWord(spath)
    {
    var pause = 0;
    var wdDialogFileOpen = 80;
    var wdApp = new ActiveXObject("Word.Application");
    wdApp.Visible = 'True';
    var wdDoc = wdApp.Documents;
    wdDoc.Open(spath);
    document.form1.submit();
    }

    </script>
     
    David C, Nov 11, 2008
    #1
    1. Advertising

  2. On Nov 11, 7:06 pm, "David C" <> wrote:
    > I have an ASP.Net page that displays documents as hyperlinks from a network
    > folder (intranet application). I also have a column that contains a
    > hyperlink to open the document in Microsoft Word.  All works fine unless
    > someone has ActiveX disabled on their browser.  Is there any way I can
    > detect that so I can give them a warning?
    >
    > The script for opening a Word document is below.  Thanks.
    >
    > -David
    >
    > <script language="javascript" type="text/javascript">
    >
    > function openWord(spath)
    > {
    >     var pause = 0;
    >     var wdDialogFileOpen = 80;
    >     var wdApp = new ActiveXObject("Word.Application");
    >     wdApp.Visible = 'True';
    >     var wdDoc = wdApp.Documents;
    >     wdDoc.Open(spath);
    >     document.form1.submit();
    >
    > }
    >
    > </script>


    Hi David,

    I think you can simply add the try..catch block to check the result of
    ActiveXObject

    try {

    var wdApp = new ActiveXObject("Word.Application");
    wdApp.Visible = 'True';
    var wdDoc = wdApp.Documents;
    wdDoc.Open(spath);
    document.form1.submit();

    } catch (er) {

    alert('You have no Word ActiveX');

    }
     
    Alexey Smirnov, Nov 12, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    900
  2. vml
    Replies:
    0
    Views:
    1,062
  3. SiuLoBow

    Detect the ActiveX Control is able to run

    SiuLoBow, Jul 9, 2004, in forum: ASP General
    Replies:
    4
    Views:
    107
    Steven Burn
    Jul 9, 2004
  4. ripken95
    Replies:
    0
    Views:
    138
    ripken95
    Jul 23, 2003
  5. Robert White
    Replies:
    0
    Views:
    135
    Robert White
    Aug 23, 2005
Loading...

Share This Page