views:

345

answers:

2

Hello all,

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>

Thanks for any help.

+1  A: 

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

Pedery
Thanks for this, the document is opening in word already and not in IE. The files I'm trying to open already exist and are not generated on the fly. I will give this a shot and see if it works anyway. I wont be able to try it until tomorrow.
Nalum
If I'm not mistaking, whether your files open in Word itself or IE depends on some registry setting. Thus you can easily override it for your own machine, but you probably want to make it open in a consistent way on all browsers. To do that you must use an approach similar to the one listed in the link above. That way you can (if you wish) provide two links to the same doc in the same webpage - one that will open in IE and one that will open in Word.
Pedery
Hello Pedery, this opens a local copy of the file as a read-only file which is fine but if a file is editable it doesn't open the original file for editing, it downloads the file as a temporary file and allows you to save. This wont work unfortunately as the users wont know where the file is on the network.
Nalum
+4  A: 

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;
});
Nalum
Thanks for posting the solution after you found it. This will help people who have the same problem in the future.
RandyMorris
No problem, I will always add my solution if I find it myself and it is not an answer already provided.Edited answer to say that jQuery is also used in the example but not required.
Nalum