public void Open(string filepath, TextBox t)
        {
            Word._Application application = new Word.Application();

            Word._Document designDocument = application.Documents.Open(filepath, ConfirmConversions: false, ReadOnly: true, AddToRecentFiles: false, Revert: false, Visible: false, OpenAndRepair: false);

            WikiFeaturePageContent content = new WikiFeaturePageContent();

            int paragraphCount = designDocument.Paragraphs.Count;

            for (int i = 1; i <= paragraphCount; i++)
            {
                if (processDocument(designDocument, ref content, ref i))
                {
                    break;
                }
            }

            designDocument.Close(SaveChanges: false);
            application.Quit(SaveChanges: false);

            t.Text = content.Purpose + content.AssumptionsAndConstraints + content.DesignConcepts;
        }
        private bool processDocument(Word._Document designDocument, ref WikiFeaturePageContent content, ref int index)
        {
            Word.Range paragraph = designDocument.Paragraphs[index].Range;
            string paragraphText = paragraph.Text;
            var style = paragraph.get_Style();
            string stylename = style != null ? style.NameLocal : String.Empty;

            if (style != null && stylename == ParagraphStyles.Heading2)
            {
                switch (paragraphText)
                {
                    case DocumentSections.Purpose:
                        content.Purpose = String.Concat("==Purpose==", Environment.NewLine, designDocument.Paragraphs[++index].Range.Text, Environment.NewLine, Environment.NewLine);
                        break;
                    case DocumentSections.Assumptions:
                        StringBuilder assumptions = new StringBuilder();
                        if (designDocument.Paragraphs[index + 1].Range.Text.StartsWith("The following assumptions and dependencies"))
                        {
                            index++;
                        }
                        do
                        {
                            index++;
                            assumptions.Append(designDocument.Paragraphs[index].Range.Text);
                        } while (designDocument.Paragraphs[index + 1].Range.Text != DocumentSections.Constraints);

                        content.Assumptions = assumptions.ToString();

                        break;
                    case DocumentSections.Constraints:
                        StringBuilder constraints = new StringBuilder();
                        if (designDocument.Paragraphs[index + 1].Range.Text.StartsWith("The following constraints"))
                        {
                            index++;
                        }
                        do
                        {
                            index++;
                            constraints.Append(designDocument.Paragraphs[index].Range.Text);
                        } while (designDocument.Paragraphs[index + 1].Range.Text != DocumentSections.DesignConcepts);

                        content.Constraints = constraints.ToString();

                        break;
                    case DocumentSections.DesignConcepts:
                        StringBuilder designConcepts = new StringBuilder("== Design Concepts ==" + Environment.NewLine);
                        if (designDocument.Paragraphs[index + 1].Range.Text.StartsWith("The following design concepts"))
                        {
                            index++;
                        }
                        do
                        {
                            index++;
                            designConcepts.AppendLine("# " + designDocument.Paragraphs[index].Range.Text);
                        } while (designDocument.Paragraphs[index + 1].Range.Text != DocumentSections.StandardMessages);

                        content.DesignConcepts = designConcepts.AppendLine().ToString();

                        return true;
                    default:
                        break;
                }
            }

            return false;
        }