Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Opening Word Document from IE

I'm opening a word document through IE on a local network, it opens up fine but if a document is password protected then it should prompt for the password which it doesn't.

Is there something that I should be doing to get the password prompt?

The way I'm opening the document is by a link on a web page e.g.

<a href="\\path\to\file.doc">Document</a>
like image 437
Nalum Avatar asked Apr 28 '10 09:04

Nalum


2 Answers

I've got what I want working using the following javascript/jQuery. jQuery is not required, I used it as I already have it as part of the project.

$('a.openDoc').live('click',function(){
    var file = $(this).attr('href');

    // This is what does the work.
    try
    {
        try
        {
            // get Word Active-X Object if Word is open.
            var word = GetObject('',"Word.Application");
        }
        catch(e)
        {
            // create new Word Active-X Object.
            var word = new ActiveXObject("Word.Application");
        }

        word.Visible = true; // Make sure Word is visible.
        word.Documents.Open(file); // Open the file you want.
    }
    catch(e)
    {
        alert(e.description);
    }
    // End work.

    return false;
});
like image 59
Nalum Avatar answered Oct 24 '22 15:10

Nalum


In case you are ok with having the document open in Word itself (and not in IE), maybe this will point you in the right direction:

http://www.velocityreviews.com/forums/t109523-open-word-doc-in-word-not-in-browser.html

like image 34
Pedery Avatar answered Oct 24 '22 16:10

Pedery