none
Jscript error in Excel app

    Question

  • Hello,

    Im taking my first steps in Office 2013 app development, when I try to run my first demo project I get the following error:

    0x800a1391 - Microsoft JScript runtime error: 'Office' is undefined

    On the first line of (generated code):

    Office.initialize = function (reason) {
        $(document).ready(function () {
            $('#getDataBtn').click(function () { getData('#selectedDataTxt'); });
    
            // If setSelectedDataAsync method is supported by the host application
            // setDatabtn is hooked up to call the method else setDatabtn is removed
            if (Office.context.document.setSelectedDataAsync) {
                $('#setDataBtn').click(function () { setData('#selectedDataTxt'); });
            }
            else {
                $('#setDataBtn').remove();
            }
        });
    };
    Anyone?
    Friday, March 29, 2013 1:30 PM

Answers

  • Are you incliding Office Javascript API in your html page? Start your app and open developer tools (F12) in IE. Go to networking tab and click start capturing. Refresh your app iframe and look if Office.js library gets included correctly.

    I think that either you are not including it in html, or that you typed the path to the library wrong.

    Also i think that you sohuld not use $(document).ready(fucntion () {} ), but instead use Office.initialize(function () {} )


    Anze Javornik

    Saturday, March 30, 2013 12:13 AM

All replies

  • Are you incliding Office Javascript API in your html page? Start your app and open developer tools (F12) in IE. Go to networking tab and click start capturing. Refresh your app iframe and look if Office.js library gets included correctly.

    I think that either you are not including it in html, or that you typed the path to the library wrong.

    Also i think that you sohuld not use $(document).ready(fucntion () {} ), but instead use Office.initialize(function () {} )


    Anze Javornik

    Saturday, March 30, 2013 12:13 AM
  • Hi,I'm Aaron .

    If you want to use Javascript Office Web App API.

    you need ref office.js in your Client Page

    like this

    <head>
    //the path should match your entity path
     <script src="../Scripts/Office/1.0/office.js"></script>
    </head>

    Monday, April 01, 2013 1:29 AM
  • Are you incliding Office Javascript API in your html page? Start your app and open developer tools (F12) in IE. Go to networking tab and click start capturing. Refresh your app iframe and look if Office.js library gets included correctly.

    I think that either you are not including it in html, or that you typed the path to the library wrong.

    Also i think that you sohuld not use $(document).ready(fucntion () {} ), but instead use Office.initialize(function () {} )


    Anze Javornik

    gt it :)
    Wednesday, December 25, 2013 4:52 PM