diff --git a/API_NetFramework/bin/DOCGEN.dll b/API_NetFramework/bin/DOCGEN.dll index 70b5c962..cdc7316d 100644 Binary files a/API_NetFramework/bin/DOCGEN.dll and b/API_NetFramework/bin/DOCGEN.dll differ diff --git a/API_NetFramework/bin/DOCGEN.pdb b/API_NetFramework/bin/DOCGEN.pdb index b4ddfce4..676140cc 100644 Binary files a/API_NetFramework/bin/DOCGEN.pdb and b/API_NetFramework/bin/DOCGEN.pdb differ diff --git a/API_NetFramework/bin/OnDocOffice.dll b/API_NetFramework/bin/OnDocOffice.dll index c8ee1eb2..ce80774d 100644 Binary files a/API_NetFramework/bin/OnDocOffice.dll and b/API_NetFramework/bin/OnDocOffice.dll differ diff --git a/API_NetFramework/bin/OnDocOffice.pdb b/API_NetFramework/bin/OnDocOffice.pdb index d1c333ea..1f405655 100644 Binary files a/API_NetFramework/bin/OnDocOffice.pdb and b/API_NetFramework/bin/OnDocOffice.pdb differ diff --git a/API_NetFramework/bin/OnDoc_NetFramework.dll b/API_NetFramework/bin/OnDoc_NetFramework.dll index cf2e30ed..0eb38801 100644 Binary files a/API_NetFramework/bin/OnDoc_NetFramework.dll and b/API_NetFramework/bin/OnDoc_NetFramework.dll differ diff --git a/API_NetFramework/bin/OnDoc_NetFramework.pdb b/API_NetFramework/bin/OnDoc_NetFramework.pdb index 7755311c..e6a52e02 100644 Binary files a/API_NetFramework/bin/OnDoc_NetFramework.pdb and b/API_NetFramework/bin/OnDoc_NetFramework.pdb differ diff --git a/API_NetFramework/obj/Debug/API_NetFramework.csproj.AssemblyReference.cache b/API_NetFramework/obj/Debug/API_NetFramework.csproj.AssemblyReference.cache index 82fcd1a6..59ce73e5 100644 Binary files a/API_NetFramework/obj/Debug/API_NetFramework.csproj.AssemblyReference.cache and b/API_NetFramework/obj/Debug/API_NetFramework.csproj.AssemblyReference.cache differ diff --git a/API_NetFramework/obj/Debug/OnDoc_NetFramework.dll b/API_NetFramework/obj/Debug/OnDoc_NetFramework.dll index cf2e30ed..0eb38801 100644 Binary files a/API_NetFramework/obj/Debug/OnDoc_NetFramework.dll and b/API_NetFramework/obj/Debug/OnDoc_NetFramework.dll differ diff --git a/API_NetFramework/obj/Debug/OnDoc_NetFramework.pdb b/API_NetFramework/obj/Debug/OnDoc_NetFramework.pdb index 7755311c..e6a52e02 100644 Binary files a/API_NetFramework/obj/Debug/OnDoc_NetFramework.pdb and b/API_NetFramework/obj/Debug/OnDoc_NetFramework.pdb differ diff --git a/BarcodeLib/obj/Debug/BarcodeLib.csproj.AssemblyReference.cache b/BarcodeLib/obj/Debug/BarcodeLib.csproj.AssemblyReference.cache index e25e7ee0..bd1eaf11 100644 Binary files a/BarcodeLib/obj/Debug/BarcodeLib.csproj.AssemblyReference.cache and b/BarcodeLib/obj/Debug/BarcodeLib.csproj.AssemblyReference.cache differ diff --git a/Client/DocMgmt/Serienbrief.cs b/Client/DocMgmt/Serienbrief.cs index 7b27d8ff..505256b6 100644 --- a/Client/DocMgmt/Serienbrief.cs +++ b/Client/DocMgmt/Serienbrief.cs @@ -263,7 +263,15 @@ namespace OnDoc.UIControls ExcelNet.ExcelReader reader = new ExcelNet.ExcelReader(); string selected_sheetname = ""; var sheets = new List(); - sheets = reader.Get_ExcelSheets(openFileDialog1.FileName); + try + { + sheets = reader.Get_ExcelSheets(openFileDialog1.FileName); + } + catch { + MessageBox.Show("Auf die gewählte Excel-Datei kann aktuell nicht zugegriffen werden. Evtl. ist diese noch geöffnet.", "Excel-Import", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (sheets.Count > 1) { DocMgmt.Serienbrief_Sheetselect sheetselect = new DocMgmt.Serienbrief_Sheetselect(sheets); @@ -1022,6 +1030,7 @@ namespace OnDoc.UIControls string check_duplicates = ""; foreach (var dup in duplicates) { + set_grid_color(dup.ToString()); if (check_duplicates != "") { check_duplicates = check_duplicates + ", "; } check_duplicates = check_duplicates + dup.ToString(); } @@ -1045,6 +1054,11 @@ namespace OnDoc.UIControls return true; } + private void set_grid_color(string partner) + { + + + } private void check_zwingende_felder() { @@ -1661,7 +1675,7 @@ namespace OnDoc.UIControls PdfDocument finalDoc = new PdfDocument(); DB db = new DB(AppParams.connectionstring); - int stapelgroesse = 100; + int stapelgroesse = 200; int stapel = 1; int i = 0; int anzahl_stapel = (dv.Count / 100) + 1; @@ -1681,10 +1695,14 @@ namespace OnDoc.UIControls if (i >= stapelgroesse) { save_stapel(stapel, ref streams); - + i = 0; - streams = new Stream[dv.Count - (stapel * stapelgroesse)]; - stapel++; + if (dv.Count-(stapel * stapelgroesse) >= stapelgroesse) { streams = new Stream[stapelgroesse]; } else + { + streams = new Stream[dv.Count - (stapel * stapelgroesse)]; + } + //streams = new Stream[dv.Count - (stapel * stapelgroesse)]; + stapel++; } } } @@ -1725,9 +1743,13 @@ namespace OnDoc.UIControls treeviewDruckstapel.Nodes.Add(tn); for (int i = 0; i < streams.Length; i++) { + streams[i].Close(); + streams[i].Dispose(); + streams[i] = null; } streams = null; + finalDoc = null; } catch { } } diff --git a/Client/Klassen/clsAppParams.cs b/Client/Klassen/clsAppParams.cs index f6d0eca1..dd38cc17 100644 --- a/Client/Klassen/clsAppParams.cs +++ b/Client/Klassen/clsAppParams.cs @@ -79,8 +79,8 @@ namespace OnDoc.Klassen EDOKAPath = db.dsdaten.Tables[0].Rows[0][12].ToString(); OfficeSpleep1 = Convert.ToInt32(db.dsdaten.Tables[0].Rows[0][13]); OfficeSpleep2 = Convert.ToInt32(db.dsdaten.Tables[0].Rows[0][14]); - pathNativVorlagen = db.dsdaten.Tables[0].Rows[0][15].ToString(); - Office_Fill_DocIO= Convert.ToInt32(db.dsdaten.Tables[0].Rows[0][15]); + pathNativVorlagen = db.dsdaten.Tables[0].Rows[0][16].ToString(); + Office_Fill_DocIO= Convert.ToInt32(db.dsdaten.Tables[0].Rows[0][17]); } else { diff --git a/Client/bin/Debug/DOCGEN.dll b/Client/bin/Debug/DOCGEN.dll index 70b5c962..cdc7316d 100644 Binary files a/Client/bin/Debug/DOCGEN.dll and b/Client/bin/Debug/DOCGEN.dll differ diff --git a/Client/bin/Debug/DOCGEN.pdb b/Client/bin/Debug/DOCGEN.pdb index b4ddfce4..676140cc 100644 Binary files a/Client/bin/Debug/DOCGEN.pdb and b/Client/bin/Debug/DOCGEN.pdb differ diff --git a/Client/bin/Debug/Office.dll b/Client/bin/Debug/Office.dll new file mode 100644 index 00000000..447c580f Binary files /dev/null and b/Client/bin/Debug/Office.dll differ diff --git a/Client/bin/Debug/OnDoc.exe b/Client/bin/Debug/OnDoc.exe index c4580aec..25aec2ae 100644 Binary files a/Client/bin/Debug/OnDoc.exe and b/Client/bin/Debug/OnDoc.exe differ diff --git a/Client/bin/Debug/OnDoc.pdb b/Client/bin/Debug/OnDoc.pdb index be6dee66..c89304af 100644 Binary files a/Client/bin/Debug/OnDoc.pdb and b/Client/bin/Debug/OnDoc.pdb differ diff --git a/Client/bin/Debug/OnDocClient.zip b/Client/bin/Debug/OnDocClient.zip index af1725a2..068d0982 100644 Binary files a/Client/bin/Debug/OnDocClient.zip and b/Client/bin/Debug/OnDocClient.zip differ diff --git a/Client/bin/Debug/OnDocOffice.dll b/Client/bin/Debug/OnDocOffice.dll index c8ee1eb2..ce80774d 100644 Binary files a/Client/bin/Debug/OnDocOffice.dll and b/Client/bin/Debug/OnDocOffice.dll differ diff --git a/Client/bin/Debug/OnDocOffice.pdb b/Client/bin/Debug/OnDocOffice.pdb index d1c333ea..1f405655 100644 Binary files a/Client/bin/Debug/OnDocOffice.pdb and b/Client/bin/Debug/OnDocOffice.pdb differ diff --git a/Client/bin/Debug/de-DE/OnDoc.resources.dll b/Client/bin/Debug/de-DE/OnDoc.resources.dll index 28c9038c..59b2282e 100644 Binary files a/Client/bin/Debug/de-DE/OnDoc.resources.dll and b/Client/bin/Debug/de-DE/OnDoc.resources.dll differ diff --git a/Client/obj/Debug/Client.csproj.AssemblyReference.cache b/Client/obj/Debug/Client.csproj.AssemblyReference.cache index eaa8df02..a69c0a47 100644 Binary files a/Client/obj/Debug/Client.csproj.AssemblyReference.cache and b/Client/obj/Debug/Client.csproj.AssemblyReference.cache differ diff --git a/Client/obj/Debug/DesignTimeResolveAssemblyReferences.cache b/Client/obj/Debug/DesignTimeResolveAssemblyReferences.cache index 5a13ae12..12d851c7 100644 Binary files a/Client/obj/Debug/DesignTimeResolveAssemblyReferences.cache and b/Client/obj/Debug/DesignTimeResolveAssemblyReferences.cache differ diff --git a/Client/obj/Debug/OnDoc.exe b/Client/obj/Debug/OnDoc.exe index c4580aec..25aec2ae 100644 Binary files a/Client/obj/Debug/OnDoc.exe and b/Client/obj/Debug/OnDoc.exe differ diff --git a/Client/obj/Debug/OnDoc.pdb b/Client/obj/Debug/OnDoc.pdb index be6dee66..c89304af 100644 Binary files a/Client/obj/Debug/OnDoc.pdb and b/Client/obj/Debug/OnDoc.pdb differ diff --git a/Client/obj/Debug/de-DE/OnDoc.resources.dll b/Client/obj/Debug/de-DE/OnDoc.resources.dll index 28c9038c..59b2282e 100644 Binary files a/Client/obj/Debug/de-DE/OnDoc.resources.dll and b/Client/obj/Debug/de-DE/OnDoc.resources.dll differ diff --git a/DOCGEN/Klassen/SyncFWord.cs b/DOCGEN/Klassen/SyncFWord.cs index 0ca6f1b4..da1c8a4d 100644 --- a/DOCGEN/Klassen/SyncFWord.cs +++ b/DOCGEN/Klassen/SyncFWord.cs @@ -160,16 +160,17 @@ namespace DOCGEN.Klassen MemoryStream ms = new MemoryStream(Helper.EncodeExtensions.DecodeBase642ByteArray(base64)); WordDocument document = new WordDocument(ms, FormatType.Automatic); CompatibilityMode compatibilityMode = document.Settings.CompatibilityMode; + Logging.Logging.Debug(compatibilityMode.ToString(), "ondoc sf", docdata.Dokumentid); switch (compatibilityMode) { case CompatibilityMode.Word2010: document.Settings.CompatibilityMode = CompatibilityMode.Word2010; break; case CompatibilityMode.Word2013: - + document.Settings.CompatibilityMode = CompatibilityMode.Word2013; break; default: - document.Settings.CompatibilityMode = CompatibilityMode.Word2003; + //document.Settings.CompatibilityMode = CompatibilityMode.Word2003; break; } //if (compatibilityMode == CompatibilityMode.Word2010) { document.Settings.CompatibilityMode = CompatibilityMode.Word2010; } @@ -308,6 +309,7 @@ namespace DOCGEN.Klassen { bookmarkNavigator.MoveToBookmark(dv.TMBeginn.ToString()); bookmarkNavigator.InsertText(dv.Value.ToString()); + bookmarkNavigator.ReplaceBookmarkContent(dv.Value.ToString(), true); } } diff --git a/DOCGEN/bin/Debug/DOCGEN.dll b/DOCGEN/bin/Debug/DOCGEN.dll index 70b5c962..cdc7316d 100644 Binary files a/DOCGEN/bin/Debug/DOCGEN.dll and b/DOCGEN/bin/Debug/DOCGEN.dll differ diff --git a/DOCGEN/bin/Debug/DOCGEN.pdb b/DOCGEN/bin/Debug/DOCGEN.pdb index b4ddfce4..676140cc 100644 Binary files a/DOCGEN/bin/Debug/DOCGEN.pdb and b/DOCGEN/bin/Debug/DOCGEN.pdb differ diff --git a/DOCGEN/bin/Debug/OnDocOffice.dll b/DOCGEN/bin/Debug/OnDocOffice.dll index c8ee1eb2..ce80774d 100644 Binary files a/DOCGEN/bin/Debug/OnDocOffice.dll and b/DOCGEN/bin/Debug/OnDocOffice.dll differ diff --git a/DOCGEN/bin/Debug/OnDocOffice.pdb b/DOCGEN/bin/Debug/OnDocOffice.pdb index d1c333ea..1f405655 100644 Binary files a/DOCGEN/bin/Debug/OnDocOffice.pdb and b/DOCGEN/bin/Debug/OnDocOffice.pdb differ diff --git a/DOCGEN/clsDocGet.cs b/DOCGEN/clsDocGet.cs index 333d2ede..2df63116 100644 --- a/DOCGEN/clsDocGet.cs +++ b/DOCGEN/clsDocGet.cs @@ -287,11 +287,13 @@ namespace DOCGEN public string Convert_Word_To_PDF(string document, DataTable pdfparameters = null, bool useseettings = false) { - + //Dokument erstellen var streamword = new MemoryStream(Convert.FromBase64String(document)); WordDocument wordDocument = new WordDocument(streamword, Syncfusion.DocIO.FormatType.Automatic); + + // Keine Parameter / Dokument als PDF konvertieren if (pdfparameters == null) { diff --git a/DOCGEN/obj/Debug/DOCGEN.dll b/DOCGEN/obj/Debug/DOCGEN.dll index 70b5c962..cdc7316d 100644 Binary files a/DOCGEN/obj/Debug/DOCGEN.dll and b/DOCGEN/obj/Debug/DOCGEN.dll differ diff --git a/DOCGEN/obj/Debug/DOCGEN.pdb b/DOCGEN/obj/Debug/DOCGEN.pdb index b4ddfce4..676140cc 100644 Binary files a/DOCGEN/obj/Debug/DOCGEN.pdb and b/DOCGEN/obj/Debug/DOCGEN.pdb differ diff --git a/DOCGEN/obj/Debug/DocGen.csproj.AssemblyReference.cache b/DOCGEN/obj/Debug/DocGen.csproj.AssemblyReference.cache index 589a49de..8f5a3fba 100644 Binary files a/DOCGEN/obj/Debug/DocGen.csproj.AssemblyReference.cache and b/DOCGEN/obj/Debug/DocGen.csproj.AssemblyReference.cache differ diff --git a/Database/obj/Debug/Database.csproj.AssemblyReference.cache b/Database/obj/Debug/Database.csproj.AssemblyReference.cache index 9d11055a..06c9a3cf 100644 Binary files a/Database/obj/Debug/Database.csproj.AssemblyReference.cache and b/Database/obj/Debug/Database.csproj.AssemblyReference.cache differ diff --git a/ExcelNet/Class1.cs b/ExcelNet/Class1.cs index a9543079..620907e5 100644 --- a/ExcelNet/Class1.cs +++ b/ExcelNet/Class1.cs @@ -11,7 +11,7 @@ namespace ExcelNet { public class ExcelReader { - + public List Get_ExcelSheets(string filename) { diff --git a/ExcelNet/FastExcel.cs b/ExcelNet/FastExcel.cs index a02dcc0a..fd68baae 100644 --- a/ExcelNet/FastExcel.cs +++ b/ExcelNet/FastExcel.cs @@ -113,9 +113,13 @@ namespace FastExcel { _templateFile = templateFile; _excelFile = excelFile; TemplateFileStream = templateFile != null ? new FileStream(templateFile.FullName, FileMode.Open, FileAccess.Read) : null; - ExcelFileStream = updateExisting - ? new FileStream(excelFile.FullName, FileMode.Open, readOnly ? FileAccess.Read : FileAccess.ReadWrite) - : new FileStream(excelFile.FullName, FileMode.OpenOrCreate, FileAccess.ReadWrite); + try + { + ExcelFileStream = updateExisting + ? new FileStream(excelFile.FullName, FileMode.Open, readOnly ? FileAccess.Read : FileAccess.ReadWrite) + : new FileStream(excelFile.FullName, FileMode.OpenOrCreate, FileAccess.ReadWrite); + } + catch { } UpdateExisting = updateExisting; ReadOnly = readOnly; diff --git a/Helper/obj/Debug/Helper.csproj.AssemblyReference.cache b/Helper/obj/Debug/Helper.csproj.AssemblyReference.cache index a046c207..a6d40828 100644 Binary files a/Helper/obj/Debug/Helper.csproj.AssemblyReference.cache and b/Helper/obj/Debug/Helper.csproj.AssemblyReference.cache differ diff --git a/Logging/obj/Debug/Logging.csproj.AssemblyReference.cache b/Logging/obj/Debug/Logging.csproj.AssemblyReference.cache index 0fa9b9cc..63a26273 100644 Binary files a/Logging/obj/Debug/Logging.csproj.AssemblyReference.cache and b/Logging/obj/Debug/Logging.csproj.AssemblyReference.cache differ diff --git a/OnDocOffice/OnDocOffice.csproj b/OnDocOffice/OnDocOffice.csproj index 67a76ab8..ec2d0d04 100644 --- a/OnDocOffice/OnDocOffice.csproj +++ b/OnDocOffice/OnDocOffice.csproj @@ -75,6 +75,10 @@ + + False + ..\VBFileManagement\bin\Debug\VBFileManagement.dll + diff --git a/OnDocOffice/bin/Debug/OnDocOffice.dll b/OnDocOffice/bin/Debug/OnDocOffice.dll index c8ee1eb2..ce80774d 100644 Binary files a/OnDocOffice/bin/Debug/OnDocOffice.dll and b/OnDocOffice/bin/Debug/OnDocOffice.dll differ diff --git a/OnDocOffice/bin/Debug/OnDocOffice.pdb b/OnDocOffice/bin/Debug/OnDocOffice.pdb index d1c333ea..1f405655 100644 Binary files a/OnDocOffice/bin/Debug/OnDocOffice.pdb and b/OnDocOffice/bin/Debug/OnDocOffice.pdb differ diff --git a/OnDocOffice/clsoffice.cs b/OnDocOffice/clsoffice.cs index 64283d06..eac8dda6 100644 --- a/OnDocOffice/clsoffice.cs +++ b/OnDocOffice/clsoffice.cs @@ -20,6 +20,7 @@ using Syncfusion.DocIO; using Syncfusion.DocIO.DLS; using System.IO; using Microsoft.VisualBasic; +using System.Net.NetworkInformation; namespace OnDocOffice { @@ -275,9 +276,14 @@ namespace OnDocOffice { try { - word = new Microsoft.Office.Interop.Word.Application(); - word.Run("Autoexec"); - word.NormalTemplate.Saved = true; + //Type WordType = Type.GetTypeFromProgID("Word.Application"); + //word = Activator.CreateInstance(WordType); + ////ExcelInst.Visible = true; + + word = (Microsoft.Office.Interop.Word.Application)Interaction.CreateObject("Word.Application"); + //word = new Microsoft.Office.Interop.Word.Application(); + word.Run("Autoexec"); + word.NormalTemplate.Saved = true; return true; } catch @@ -286,6 +292,7 @@ namespace OnDocOffice } } + public void Edit_Document(bool runmacros) { Start_Application(); @@ -350,6 +357,53 @@ namespace OnDocOffice } } + public void Word_Compatibility_Mode (ref WordDocument wd) + { + CompatibilityMode compatibilityMode = wd.Settings.CompatibilityMode; + var formattype_original = wd.ActualFormatType; + switch (compatibilityMode) + { + case CompatibilityMode.Word2010: + wd.Settings.CompatibilityMode = CompatibilityMode.Word2010; + break; + case CompatibilityMode.Word2013: + wd.Settings.CompatibilityMode = CompatibilityMode.Word2013; + break; + default: +// wd.Settings.CompatibilityMode = CompatibilityMode.Word2003; + break; + } + } + private string set_cmode(string file) + { + string formattype = ""; + MemoryStream ms = new MemoryStream(Helper.EncodeExtensions.DecodeBase642ByteArray(file)); + WordDocument document = new WordDocument(ms, FormatType.Automatic); + CompatibilityMode compatibilityMode = document.Settings.CompatibilityMode; + formattype = document.ActualFormatType.ToString(); + var formattype_original = document.ActualFormatType; + Word_Compatibility_Mode(ref document); + //switch (compatibilityMode) + //{ + // case CompatibilityMode.Word2010: + // document.Settings.CompatibilityMode = CompatibilityMode.Word2010; + // break; + // case CompatibilityMode.Word2013: + // document.Settings.CompatibilityMode = CompatibilityMode.Word2010; + // break; + // default: + // document.Settings.CompatibilityMode = CompatibilityMode.Word2003; + // break; + //} + MemoryStream destms = new MemoryStream(); + document.Save(destms,formattype_original); + + document.Close(); + document.Dispose(); + byte[] imageArray = destms.ToArray(); + + return Convert.ToBase64String(imageArray); + } public string Generate_Word_in_Office(ref clsDocData docdata, ref clsdok dok, string vorlage, string connectionstring, string tempdir, string dokumentid, string apptype, string extension, int OfficeSleep, int bookmarks_docio) { this.dokumentid = docdata.Dokumentid; @@ -357,85 +411,94 @@ namespace OnDocOffice int pos = 0; int pos2 = 0; + VBFileManagement.VBFileManagement vb = new VBFileManagement.VBFileManagement(); + vb.Get_From_DB(Convert.ToInt32(docdata.VorlageNr), filename, connectionstring, false); + Helper.clsFileHelper fh = new Helper.clsFileHelper(); + vorlage = fh.Base64FromFile(filename); + vorlage = set_cmode(vorlage); + fh.SaveBase64ToFile(vorlage, filename); + Logging.Logging.Debug("Generate_Word_in_Office", "clsOffice", dokumentid); Start_Application(); - Logging.Logging.Debug("Ende Start_Application", "clsOffice", dokumentid); + // Thread.Sleep(OfficeSleep); worddoc = word.Documents.Open(filename); - + Thread.Sleep(OfficeSleep); string ext = System.IO.Path.GetExtension(filename).ToUpper(); - switch (word.ActiveDocument.CompatibilityMode) - { - case 14: - switch (ext) - { - case ".DOCX": - word.ActiveDocument.SaveAs2(filename, CompatibilityMode: 14, FileFormat: Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatXMLDocument); - break; - case ".DOCM": - word.ActiveDocument.SaveAs2(filename, CompatibilityMode: 14, FileFormat: Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatXMLDocumentMacroEnabled); - break; - case ".DOTX": - word.ActiveDocument.SaveAs2(filename, FileFormat: Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatXMLTemplate, CompatibilityMode: 14); - break; - case "DOTM": - word.ActiveDocument.SaveAs2(filename, FileFormat: Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatXMLTemplateMacroEnabled, CompatibilityMode: 14); - break; - } - break; - case 15: - case 16: - case 17: - case 18: - switch (ext) - { - case ".DOCX": - word.ActiveDocument.SaveAs2(filename, FileFormat: Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatXMLDocument); - break; - case ".DOCM": - word.ActiveDocument.SaveAs2(filename, FileFormat: Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatXMLDocumentMacroEnabled); - break; - case ".DOTX": - word.ActiveDocument.SaveAs2(filename, FileFormat: Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatXMLTemplate); - break; - case "DOTM": - word.ActiveDocument.SaveAs2(filename, FileFormat: Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatXMLTemplateMacroEnabled); - break; - } - - break; - default: - switch (ext) - { - case ".DOCX": - word.ActiveDocument.SaveAs2(filename, CompatibilityMode: 11, FileFormat: Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatXMLDocument); - break; - case ".DOCM": - word.ActiveDocument.SaveAs2(filename, CompatibilityMode: 11, FileFormat: Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatXMLDocumentMacroEnabled); - break; - case ".DOTX": - word.ActiveDocument.SaveAs2(filename, FileFormat: Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatXMLTemplate, CompatibilityMode: 11); - break; - case "DOTM": - word.ActiveDocument.SaveAs2(filename, FileFormat: Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatXMLTemplateMacroEnabled, CompatibilityMode: 11); - break; - } - break; - - - } - - - Logging.Logging.Debug("Word Open", "clsOffice", dokumentid); - + Logging.Logging.Debug(word.ActiveDocument.CompatibilityMode.ToString(), ext, dokumentid); + //switch (word.ActiveDocument.CompatibilityMode) + //{ + // case 14: + // switch (ext) + // { + // case ".DOCX": + // word.ActiveDocument.SaveAs2(filename, CompatibilityMode:14, FileFormat: Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatXMLDocument); + // break; + // case ".DOCM": + // word.ActiveDocument.SaveAs2(filename, CompatibilityMode:14, FileFormat: Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatXMLDocumentMacroEnabled); + // break; + // case ".DOTX": + // word.ActiveDocument.SaveAs2(filename, FileFormat: Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatXMLTemplate, CompatibilityMode: 14); + // break; + // case "DOTM": + // word.ActiveDocument.SaveAs2(filename, FileFormat: Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatXMLTemplateMacroEnabled, CompatibilityMode: 14); + // break; + // } + // break; + // case 15: + // case 16: + // case 17: + // case 18: + // switch (ext) + // { + // case ".DOCX": + // word.ActiveDocument.SaveAs2(filename, FileFormat: Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatXMLDocument); + // break; + // case ".DOCM": + // word.ActiveDocument.SaveAs2(filename, FileFormat: Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatXMLDocumentMacroEnabled); + // break; + // case ".DOTX": + // word.ActiveDocument.SaveAs2(filename, FileFormat: Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatXMLTemplate); + // break; + // case "DOTM": + // word.ActiveDocument.SaveAs2(filename, FileFormat: Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatXMLTemplateMacroEnabled); + // break; + // } + + // break; + // default: + // switch (ext) + // { + // case ".DOCX": + // word.ActiveDocument.SaveAs2(filename, CompatibilityMode: 11, FileFormat: Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatXMLDocument); + // break; + // case ".DOCM": + // word.ActiveDocument.SaveAs2(filename, CompatibilityMode: 11, FileFormat: Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatXMLDocumentMacroEnabled); + // break; + // case ".DOTX": + // word.ActiveDocument.SaveAs2(filename, FileFormat: Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatXMLTemplate, CompatibilityMode: 11); + // break; + // case "DOTM": + // word.ActiveDocument.SaveAs2(filename, FileFormat: Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatXMLTemplateMacroEnabled, CompatibilityMode: 11); + // break; + // } + // break; + + + //} + + word.NormalTemplate.Saved = true; + //word.ActiveDocument.Close(false); Thread.Sleep(OfficeSleep); + //worddoc = word.Documents.Open(filename); + Logging.Logging.Debug("Word Open", "clsOffice", dokumentid); Logging.Logging.Debug("Word befüllen", "clsOffice", dokumentid); - + Thread.Sleep(OfficeSleep); if (worddoc.ProtectionType != Microsoft.Office.Interop.Word.WdProtectionType.wdNoProtection) { worddoc.Unprotect(Password: "Australia"); @@ -573,12 +636,17 @@ namespace OnDocOffice if (is_protected) { - worddoc.Protect(Type: Microsoft.Office.Interop.Word.WdProtectionType.wdAllowOnlyFormFields, NoReset: true, Password: "Australia"); + try + { + worddoc.Protect(Type: Microsoft.Office.Interop.Word.WdProtectionType.wdAllowOnlyFormFields, NoReset: true, Password: "Australia"); + } + catch { } } //word.Visible = true; Logging.Logging.Debug("Start Macros", "clsOffice", dokumentid); run_macros(ref docdata, connectionstring); + worddoc.Save(); Logging.Logging.Debug("Word Saved", "clsOffice", dokumentid); @@ -932,6 +1000,22 @@ namespace OnDocOffice using (FileStream inputFileStream = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) ; WordDocument document = new WordDocument(); document.Open(filename, FormatType.Automatic); + Word_Compatibility_Mode(ref document); + //CompatibilityMode compatibilityMode = document.Settings.CompatibilityMode; + + //var formattype_original = document.ActualFormatType; + //switch (compatibilityMode) + //{ + // case CompatibilityMode.Word2010: + // document.Settings.CompatibilityMode = CompatibilityMode.Word2010; + // break; + // case CompatibilityMode.Word2013: + // document.Settings.CompatibilityMode = CompatibilityMode.Word2010; + // break; + // default: + // document.Settings.CompatibilityMode = CompatibilityMode.Word2003; + // break; + //} foreach (clsDocValue dv in docdata.DocValues) { if (docdata.Form_ohne_Unterschrift == "True") @@ -1025,8 +1109,18 @@ namespace OnDocOffice } else { - bookmarkNavigator.MoveToBookmark(dv.TMBeginn.ToString()); - bookmarkNavigator.InsertText(dv.Value.ToString()); + Syncfusion.DocIO.DLS.Bookmark bookmark; + bookmark = document.Bookmarks.FindByName(dv.TMBeginn.ToString()); + if (bookmark != null) + { + bookmarkNavigator.MoveToBookmark(dv.TMBeginn.ToString(),true,false); + bookmarkNavigator.MoveToBookmark(dv.TMBeginn.ToString()); + bookmarkNavigator.InsertText(dv.Value.ToString()); + bookmarkNavigator.ReplaceBookmarkContent(dv.Value.ToString(),true); + //TextBodyPart bookmarkContent = bookmarkNavigator.GetBookmarkContent(); + //string bookmarkText = ((Syncfusion.DocIO.DLS.WParagraph)bookmarkContent.BodyItems.FirstItem).Text; + + } } } diff --git a/OnDocOffice/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/OnDocOffice/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache index b2f7a950..0d756070 100644 Binary files a/OnDocOffice/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache and b/OnDocOffice/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/OnDocOffice/obj/Debug/OnDocOffice.csproj.AssemblyReference.cache b/OnDocOffice/obj/Debug/OnDocOffice.csproj.AssemblyReference.cache index 558bb3ac..5cb8a3dc 100644 Binary files a/OnDocOffice/obj/Debug/OnDocOffice.csproj.AssemblyReference.cache and b/OnDocOffice/obj/Debug/OnDocOffice.csproj.AssemblyReference.cache differ diff --git a/OnDocOffice/obj/Debug/OnDocOffice.csproj.CoreCompileInputs.cache b/OnDocOffice/obj/Debug/OnDocOffice.csproj.CoreCompileInputs.cache index df8bda2f..ee0a7927 100644 --- a/OnDocOffice/obj/Debug/OnDocOffice.csproj.CoreCompileInputs.cache +++ b/OnDocOffice/obj/Debug/OnDocOffice.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -eb32d9bf6208a44886b912603a96aa2b1a08a09956beecde6f8f08a4d00296ba +884c6102be53750b3d358cc632173bd7eedf7e2f767ce1a2dcb3e182bfc74fa2 diff --git a/OnDocOffice/obj/Debug/OnDocOffice.dll b/OnDocOffice/obj/Debug/OnDocOffice.dll index c8ee1eb2..ce80774d 100644 Binary files a/OnDocOffice/obj/Debug/OnDocOffice.dll and b/OnDocOffice/obj/Debug/OnDocOffice.dll differ diff --git a/OnDocOffice/obj/Debug/OnDocOffice.pdb b/OnDocOffice/obj/Debug/OnDocOffice.pdb index d1c333ea..1f405655 100644 Binary files a/OnDocOffice/obj/Debug/OnDocOffice.pdb and b/OnDocOffice/obj/Debug/OnDocOffice.pdb differ