/// <summary> /// Starts the calculation of word frequencies by getting an array of all words in the current document. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void bgWorker_DoWork(object sender, DoWorkEventArgs e) { Microsoft.Office.Interop.Word.Application app = Globals.ThisAddIn.Application; //Select the range as the entire document. object start = 0; object end = app.ActiveDocument.Characters.Count; Microsoft.Office.Interop.Word.Range rng = app.ActiveDocument.Range(ref start, ref end); Words words = app.ActiveDocument.Words; this.wordcount = app.ActiveDocument.Words.Count; //TODO - parellilize this with multiple background workers. here or in the ribbon class? FrequencyCalculation m = new FrequencyCalculation(bgWorker, words, 1, wordcount, (bool)e.Argument); e.Result = m.getResult(); }