private static void SaveOptionsAndExport(TextDocument document, OpenXMLExportOptions exportOptions)
        {
            document.PropertyBagNotNull.SetValue(PropertyKeyOpenXMLExportOptions, (OpenXMLExportOptions)exportOptions.Clone());
            Current.PropertyService.ApplicationSettings.SetValue(PropertyKeyOpenXMLExportOptions, (OpenXMLExportOptions)exportOptions.Clone());

            var errors = new List <MarkdownError>();

            exportOptions.Export(document, exportOptions.OutputFileName, errors);

            if (errors.Count > 0)
            {
                var stb = new StringBuilder();
                stb.AppendLine("There were error(s) during export:");
                stb.AppendLine();

                foreach (var error in errors)
                {
                    stb.AppendLine(error.ToString());
                }

                Current.Gui.ErrorMessageBox(stb.ToString(), "Export errors");
                return;
            }


            // Start Sandcastle help file builder
            if (exportOptions.OpenApplication)
            {
                System.Diagnostics.Process.Start(exportOptions.OutputFileName);
            }
        }