diff --git a/zaaReloaded2/Formatter/Formatter.cs b/zaaReloaded2/Formatter/Formatter.cs index 6639198..185e1cd 100755 --- a/zaaReloaded2/Formatter/Formatter.cs +++ b/zaaReloaded2/Formatter/Formatter.cs @@ -121,6 +121,14 @@ namespace zaaReloaded2.Formatter { if (!CanRun) throw new NoLaboratoryDataException("No laboratory data to format."); + // Create undo record and styles prior to iterating over the elements + // because a column switching element might trigger output to the + // document. + Globals.ThisAddIn.Application.UndoRecord.StartCustomRecord( + String.Format("Laborformatierung ({0})", Properties.Settings.Default.AddinName) + ); + CreateStyles(); + int current = 0; while (current < Settings.Elements.Count) { @@ -146,11 +154,6 @@ namespace zaaReloaded2.Formatter } } - // Write everything to the Word document - Globals.ThisAddIn.Application.UndoRecord.StartCustomRecord( - String.Format("Laborformatierung ({0})", Properties.Settings.Default.AddinName) - ); - CreateStyles(); _secondaryBuffer.Flush(); Globals.ThisAddIn.Application.UndoRecord.EndCustomRecord(); }