Pages

9/29/2014

Script: Time To Open Word Document

I want to time how long it takes to open a Word document over the WAN.

var myApp = new ActiveXObject("Word.Application");
myApp.Visible = true;
// Remember when we started
var start = new Date().getTime();
  myApp.Documents.Open("Z:\\openword\\1M.doc");
  //myApp.ActiveDocument.SaveAs("Z:\\openword\\1M.doc");
  myApp.Documents.Close();
// Remember when we finished
myApp.Application.Quit();
var end = new Date().getTime();
// Now calculate and output the difference
var time = end - start;
var mo = new Date().getMonth()+1;
if (mo < 10) { mo = "0" + mo };
var day = new Date().getDate();
if (day < 10) {day = "0" + day};
var year = new Date().getFullYear();
var hrs = new Date().getHours();
if (hrs < 10) {hrs = "0" + hrs};
var m = new Date().getMinutes();
if (m < 10) {m = "0" + m};
var s = new Date().getSeconds();
if (s < 10) {s = "0" + s};
var dt = mo + "/" + day + "/" + year + " " + hrs + ":" + m + ":" + s
WScript.Echo(dt, time / 1000);
save as c:\temp\testword.js run from CMD.EXE: cscript c:\temp\testword.js Will output something like: 9/29/2014 22:43:25 , 3.252

No comments: