private bool hasWord2013OrLater()
        {
            WordInterface word    = new WordInterface();
            float         version = word.getWordVersion();

            Console.WriteLine(version);
            word.Quit();
            return(version > 14.99);
        }
        protected override void generateReport(object sender, DoWorkEventArgs args)
        {
            GeneratePerformanceLevelReportEvent e = args as GeneratePerformanceLevelReportEvent;

            if (e == null)
            {
                throw new Exception("No generate performance level report event args parsed");
            }

            Document wordDocument = null;

            //Create a word interface so we can talk easilie to word.
            WordInterface wordInterface = new WordInterface();

            try
            {
                // Open a new document.
                FileStream newDocument = File.Create((string)e.newDocumentLocation + ".docx");
                newDocument.Close();
                newDocument = null;

                //Create our output document.
                wordDocument = wordInterface.app.Documents.Open(e.newDocumentLocation + ".docx");

                //Get some data out of the database.
                DataRow  projectInfoRow = tbl_Risk_AnalysisTableAdapter.GetData().FindByProjectID(e.projectID);
                DataView riskDataRows   = new DataView(this.get_Risks_With_PL_In_ProjectTableAdapter.GetData(e.projectID));
                riskDataRows.Sort = ARA_Globals.RiskSortingOptions[e.sortingKey];

                //Set generating process.

                backgroundWorker1.ReportProgress(5, (object)"Generating front page.");

                generateFrontPage(e.frontPageTemplateLocation, wordInterface, wordDocument, projectInfoRow);

                backgroundWorker1.ReportProgress(15, (object)"Generating PL pages.");

                generateRiskPages(e.riskPageTemplateLocation, wordInterface, wordDocument, riskDataRows, projectInfoRow);

                backgroundWorker1.ReportProgress(68, (object)"Adding watermarks(if needed).");

                setWaterMark(wordInterface, wordDocument, projectInfoRow["StateName"].ToString(), projectInfoRow["DraftVersion"].ToString());

                backgroundWorker1.ReportProgress(70, (object)"Saving the document.");

                wordInterface.saveDocument(wordDocument, (string)e.newDocumentLocation);

                backgroundWorker1.ReportProgress(90, (object)"Converting document to pdf.");

                wordInterface.saveDocumentAsPdf(wordDocument, (string)e.newDocumentLocation);

                backgroundWorker1.ReportProgress(100, (object)"Done generating.");

                //Do we need to cancel the backgroundworker?
                if (backgroundWorker1.CancellationPending)
                {
                    args.Cancel = true;
                }
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ARA_Constants.messageBoxSomethingWrongWhileGenerating + ex.Message, ARA_Constants.messageBoxSomethingWrongWhileGeneratingHeader, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            finally
            {
                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();
                GC.WaitForPendingFinalizers();
            }

            // Close and release the Document object.
            if (wordDocument != null)
            {
                wordDocument.Close();
                wordDocument = null;
            }
            //Clean the word interface.
            wordInterface.Quit();
            wordInterface = null;
        }