OmnipresentPerception
OmnipresentPerception

Reputation: 93

Elapsed Time for Open a Microsoft Word Document

it's possible to calculate the elapsed time from the "opening" of a word document( operation normally made by double click on the document) until the effective view of the document in Word?

I thinked that the start of my timespan may be the process.Start of the application. But how can i know when the document is effectively opened in Microsoft Word?

Upvotes: 0

Views: 726

Answers (1)

Thibaut
Thibaut

Reputation: 152

Interop is synchronous so you should be able to do this :

string path = "";
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
var excel = new Microsoft.Office.Interop.Excel.Application();
excel.Workbooks.Open(path, Type.Missing, false, Type.Missing, Type.Missing,
                Type.Missing, false, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                Type.Missing, Type.Missing, Type.Missing);
stopWatch.Stop();
// Get the elapsed time as a TimeSpan value.
TimeSpan ts = stopWatch.Elapsed;

// Format and display the TimeSpan value.
string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
            ts.Hours, ts.Minutes, ts.Seconds,
            ts.Milliseconds / 10);
Console.WriteLine("RunTime " + elapsedTime);
Console.ReadKey();

Upvotes: 1

Related Questions