Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Microsoft Office 2013 javascript API in standalone script

I have Microsoft Office 2013 installed in a Windows 7 machine. After several searches could not find and example or tutorial that shows how to use standalone JavaScript for scripting Microsoft Office 2013, that is without integrating it in a web page (HTML file) or creating UI components, specifically for modifying contents of MS Word or MS Excel. How can this be accomplished do this?

like image 718
Amani Avatar asked Aug 23 '26 01:08

Amani


1 Answers

You can run JavaScript code on Windows without a browser using Windows Script Host. I believe by default .js files are associated with wscript.exe, which runs the script without a console. You can also run them with access to a console via cscript.exe, e.g.:

cscript.exe /nologo yourfile.js

You can then get access to Office via ActiveXObject, e.g.:

var excel = new ActiveXObject("Excel.Application");

That gives you access to the COM API.

like image 193
T.J. Crowder Avatar answered Aug 25 '26 14:08

T.J. Crowder