سؤال

I have an HTML page that has a link to open Microsoft Word on the local machine. The code runs fine while I am running in .NET. Once it is published to a server, ActiveXObject fails without returning any message or Inner Exception.

Has anyone else encountered this before. Since this is running at the client in javascript, I don't understand why it would fail.

function WordCallback(filename) {
    var word;
    try {
        word = new ActiveXObject("Word.Application"); //fails here 
    }
    catch (e) {
        $.colorbox.close();
        alert('This functionality only works with Internet Explorer.');
        return false;
    }

    try {
        //open the document using word
        word.Documents.Open(filename);
        word.Visible = true; // Make sure Word is visible.
        word.Activate();
    }
    catch (e) {
        alert('Unable to open the document.');
    }
    return false;
}
هل كانت مفيدة؟

المحلول

Its most likely failing because

  • the client does not have Word installed
  • the server/site is not trusted
  • the browser's security does not allow ActiveXObject's to be created

The most likely error is that your server/site is not trusted by the browser. See Allowing ActiveXObject for a trusted site or http://support.microsoft.com/kb/832512

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top