3

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?

wattostudios
  • 8,666
  • 13
  • 43
  • 57
Amani
  • 16,245
  • 29
  • 103
  • 153

1 Answers1

1

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.

T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875
  • my intention is to use the New JavaScript API that comes with Office 2013. I'm not conversant with COM API. I do not know, does the New JavaScript API needs one to know COM? – Amani Jun 29 '13 at 07:23
  • @Amani: I don't know how to get access to the new JavaScript API in this environment, sorry. You don't need to know COM to use the COM API, it's just an API (objects, methods, properties...). The COM API was the main API to Office for 20 years or so, most of the examples you see relate to it. But yes, things are moving on (finally!). :-) – T.J. Crowder Jun 29 '13 at 07:30