Search code examples
node.jsoffice365ms-officeoffice-jsoffice-addins

Office JavaScript API running under the hood


Please correct me if I am wrong, I am pretty confused as to how Office Add-in works under the hood:-

  1. When I made a Office JavaScript API call within an Office Addin (which is an embedded browser), the request is being handled by Node.js and will be routed to the proper destination in the Office desktop application?

  2. Then, how will the Office desktop application process with the request? Are there any ways to look into the source code on what code it would run based on the specific javascript call?


Solution

    1. Your JavaScript code that calls Office JavaScript APIs runs in the JavaScript runtime of the embedded browser, not in Node.js. (Node.js does not run in a browser or embedded browser.)

    2. Office.js uses the JavaScript runtime's ability to call out to its host to call out to the hosting Office application. Office translates the call into a C++ call to the Office application's DLLs. If the call returns anything, this is passed by Office back to the JavaScript runtime, which passes it back to your calling code. The Office Suite is not open source and I don't think there is any public mapping of the Office JavaScript APIs to the internal C++ code.