/// <summary> /// make sure internal bookmark and word bookmark are match /// </summary> /// <returns></returns> private bool ValidateBookmark(List <string> highlightedBmKeys, WdColorIndex color) { try { // update word bm List <string> removedWord = ValidateWordBookmark(color); highlightedBmKeys.AddRange(removedWord); // update internal bookmark (remove bm exist in internal but not exist in word) ValidateInternalBookmark(); return(removedWord.Count == 0); } catch (BaseException baseExp) { ManagerException mgrExp = new ManagerException(ErrorCode.ipe_ValidateBookmarkError); mgrExp.Errors.Add(baseExp); throw mgrExp; } catch (System.Exception ex) { ManagerException mgrExp = new ManagerException(ErrorCode.ipe_ValidateBookmarkError, MessageUtils.Expand(Properties.Resources.ipe_ValidateWordBookmarkWithDomainError, ex.Message), ex.StackTrace); throw mgrExp; } }
/// <summary> /// highlight bookmark /// </summary> /// <param name="name"></param> private void HighLightBookmark(string name, WdColorIndex color) { Bookmark bm = GetBookmark(name); if (bm != null) { bm.Range.HighlightColorIndex = color; bm.Range.Font.ColorIndex = ProntoMarkup.ForeColorHighLight; } }
private static void addTextSample(ref Document document, WdColorIndex color, string text) { int before = getLastPosition(ref document); Range rng = document.Range(document.Content.End - 1, document.Content.End - 1); rng.Text += text; int after = getLastPosition(ref document); document.Range(before, after).Font.ColorIndex = color; }
/// <summary> /// 文書の末尾に属性テキストを追加する. /// </summary> private void addAttributeText_detail(ref Document document, WdColorIndex color, string text) { int before = getLastPosition(ref document); Range rng = document.Range(document.Content.End - 1, document.Content.End - 1); rng.Text += text; int after = getLastPosition(ref document); document.Range(before, after).Font.ColorIndex = color; document.Range(before, after).Font.Size = 8; }
/// <summary> /// validate bookmark position (open tag and close tag must be have same node level) /// </summary> /// <param name="Doc"></param> /// <returns></returns> private bool ValidateData(List <string> highlightedBmKeys, WdColorIndex color) { try { XmlDocument xDoc = new XmlDocument(); string abc = _doc.WordOpenXML; xDoc.LoadXml(_doc.WordOpenXML); foreach (Bookmark bm in _doc.Bookmarks) { string startBmName = bm.Name; string endBmName = string.Empty; if (startBmName.EndsWith(ProntoMarkup.KeyStartForeach)) { endBmName = bm.Name.Replace(ProntoMarkup.KeyStartForeach, ProntoMarkup.KeyEndForeach); } else if (startBmName.EndsWith(ProntoMarkup.KeyStartIf)) { endBmName = bm.Name.Replace(ProntoMarkup.KeyStartIf, ProntoMarkup.KeyEndIf); } if (!string.IsNullOrEmpty(endBmName)) { if (!ValidateBookmark(xDoc, startBmName, endBmName)) { highlightedBmKeys.Add(startBmName); highlightedBmKeys.Add(endBmName); HighLightBookmark(startBmName, color); HighLightBookmark(endBmName, color); return(false); } } } return(true); } catch (BaseException baseExp) { ManagerException mgrExp = new ManagerException(ErrorCode.ipe_ValidateDataError); mgrExp.Errors.Add(baseExp); throw mgrExp; } catch (System.Exception ex) { ManagerException mgrExp = new ManagerException(ErrorCode.ipe_ValidateDataError, MessageUtils.Expand(Properties.Resources.ipe_ValidateWordBookmarkError, ex.Message), ex.StackTrace); throw mgrExp; } }
/// <summary> /// 文書のフッターを編集する. /// </summary> private void editFooterSample(ref Document document, int fontSize, WdColorIndex color, string text) { foreach (Section wordSection in document.Sections) { //Get the footer range and add the footer details. Range footerRange = wordSection.Footers[WdHeaderFooterIndex.wdHeaderFooterPrimary].Range; footerRange.Font.ColorIndex = color; footerRange.Font.Size = fontSize; footerRange.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter; footerRange.Text = text; } }
private void AddTableContent(List <Tesis> tesisAImprimir, string tabletitle, string tipoTesis) { int fila = 1; Range wrdRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range; Table oTable = oDoc.Tables.Add(wrdRng, tesisAImprimir.Count + 3, 3, ref oMissing, ref oMissing); //oTable.Rows[1].HeadingFormat = 1; oTable.Range.ParagraphFormat.SpaceAfter = 6; oTable.Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter; oTable.Range.Font.Size = 9; oTable.Range.Font.Name = "Arial"; oTable.Range.Font.Bold = 0; oTable.Borders.Enable = 1; oTable.Columns[1].SetWidth(60, WdRulerStyle.wdAdjustSameWidth); oTable.Columns[2].SetWidth(80, WdRulerStyle.wdAdjustSameWidth); oTable.Columns[3].SetWidth(300, WdRulerStyle.wdAdjustSameWidth); oTable.Rows[fila].Cells[1].Merge(oTable.Rows[fila].Cells[3]); oTable.Rows[fila].Range.Text = tabletitle; fila++; oTable.Rows[fila].Cells[1].Merge(oTable.Rows[fila].Cells[3]); oTable.Rows[fila].Range.Text = tipoTesis; fila++; oTable.Cell(fila, 1).Range.Text = "Consecutivo"; oTable.Cell(fila, 2).Range.Text = "Núm. de identificación de la tesis"; oTable.Cell(fila, 3).Range.Text = "Título y subtítulo"; fila++; int consecutivo = 1; foreach (Tesis print in tesisAImprimir) { WdColorIndex cellColor = this.GetCellColor(print.IdColor); oTable.Cell(fila, 1).Range.Text = consecutivo.ToString(); oTable.Cell(fila, 1).Range.Font.ColorIndex = cellColor; oTable.Cell(fila, 2).Range.Text = print.ClaveTesis; oTable.Cell(fila, 2).Range.Font.ColorIndex = cellColor; oTable.Cell(fila, 3).Range.Text = print.Rubro; oTable.Cell(fila, 3).Range.Font.ColorIndex = cellColor; oTable.Cell(fila, 3).Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphJustify; fila++; consecutivo++; } }
/// <summary> /// 文書のヘッダーを編集する. /// </summary> private void editHeaderSample(ref Document document, int fontSize, WdColorIndex color, string text) { foreach (Section section in document.Sections) { //Get the header range and add the header details. Range headerRange = section.Headers[WdHeaderFooterIndex.wdHeaderFooterPrimary].Range; headerRange.Fields.Add(headerRange, WdFieldType.wdFieldPage); headerRange.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter; headerRange.Font.ColorIndex = color; headerRange.Font.Size = fontSize; headerRange.Text = text; } }
////////////////////////////////////////// // 复制ClassShading同名参数值 public void clone(ClassShading shd) { this.BackgroundPatternColor = shd.BackgroundPatternColor; // 复制ClassShading同名参数值 this.BackgroundPatternColorIndex = shd.BackgroundPatternColorIndex; // 复制ClassShading同名参数值 //this.Creator = shd.Creator;// 复制ClassShading同名参数值 this.ForegroundPatternColor = shd.ForegroundPatternColor; // 复制ClassShading同名参数值 this.ForegroundPatternColorIndex = shd.ForegroundPatternColorIndex; // 复制ClassShading同名参数值 this.Texture = shd.Texture; // 复制ClassShading同名参数值 return; }
//////////////////////////////////////////// // 复制ClassBorder对象的内容 public void clone(ClassBorder obd) { this.ArtStyle = obd.ArtStyle; // 进行赋值 this.ArtWidth = obd.ArtWidth; // 进行赋值 this.Color = obd.Color; // 进行赋值 this.ColorIndex = obd.ColorIndex; // 进行赋值 this.Creator = obd.Creator; // 进行赋值 this.Inside = obd.Inside; // 进行赋值 this.LineStyle = obd.LineStyle; // 进行赋值 this.LineWidth = obd.LineWidth; // 进行赋值 this.Visible = obd.Visible; // 进行赋值 return; }
private bool ValidateDocument(WdColorIndex color) { if (Wkl.MainCtrl.CommonCtrl.CommonProfile.Bookmarks.Count > 0) { ContextManager contextMgr = new ContextManager(); string mgrKey = string.Empty; Pdw.WKL.Profiler.Manager.ManagerProfile mgrPro = Wkl.MainCtrl.ManagerCtrl.CreateProfile(out mgrKey); mgrPro.WdColorIndex = color; mgrPro.IsSaveDocument = false; contextMgr.ValidateDocument(mgrKey); return(mgrPro.IsCorrect); } return(false); }
////////////////////////// public void clone(ClassBorders obds) { this.AlwaysInFront = obds.AlwaysInFront; this.Count = obds.Count; this.Creator = obds.Creator; this.DistanceFrom = obds.DistanceFrom; this.DistanceFromBottom = obds.DistanceFromBottom; this.DistanceFromLeft = obds.DistanceFromLeft; this.DistanceFromRight = obds.DistanceFromRight; this.DistanceFromTop = obds.DistanceFromTop; this.Enable = obds.Enable; this.EnableFirstPageInSection = obds.EnableFirstPageInSection; this.EnableOtherPagesInSection = obds.EnableOtherPagesInSection; this.HasHorizontal = obds.HasHorizontal; this.HasVertical = obds.HasVertical; this.InsideColor = obds.InsideColor; this.InsideColorIndex = obds.InsideColorIndex; this.InsideLineStyle = obds.InsideLineStyle; this.InsideLineWidth = obds.InsideLineWidth; this.JoinBorders = obds.JoinBorders; this.OutsideColor = obds.OutsideColor; this.OutsideColorIndex = obds.OutsideColorIndex; this.OutsideLineStyle = obds.OutsideLineStyle; this.OutsideLineWidth = obds.OutsideLineWidth; this.Shadow = obds.Shadow; this.SurroundFooter = obds.SurroundFooter; this.SurroundHeader = obds.SurroundHeader; this.m_hashBorder.Clear(); ClassBorder bd = null; for (int i = (int)WdBorderType.wdBorderVertical; i <= (int)WdBorderType.wdBorderTop; i++) { bd = (ClassBorder)obds[(WdBorderType)i]; if (bd != null) { ClassBorder classBd = new ClassBorder(); classBd.clone(bd); m_hashBorder[i] = classBd; } } return; }
/// <summary> /// validate word bookmark (if exist in word but not exit in internal => highlight and markup to return) /// </summary> /// <param name="iBms"></param> /// <returns></returns> private List <string> ValidateWordBookmark(WdColorIndex color) { List <string> deletedList = new List <string>(); foreach (Bookmark wBm in _doc.Bookmarks) { InternalBookmarkItem item = iBm.GetInternalBookmarkItem(wBm.Name); // 1. check null (can not find ibm) if (item == null) { // todo: ngocbv_rem => confirm to remove export item //if (!MarkupUtilities.IsProntoDocCommentBookmark(wBm.Name)) //{ // deletedList.Add(wBm.Name); // HighLightBookmark(wBm.Name, color); //} continue; } // 2. get real biz name string bizName = item.IsImage() ? MarkupUtilities.GetBizNameOfBookmarkImage(wBm.Name, _doc.InlineShapes) : wBm.Range.Text; if (item.BizName != bizName) // compare key and value { deletedList.Add(wBm.Name); HighLightBookmark(wBm.Name, color); } else if (item != null && item.Type == XsltType.Select) // check match with domain (only check for field) { DomainInfo domainInfo = Wkl.MainCtrl.CommonCtrl.GetDomainInfo(item.DomainName); if (domainInfo != null && !domainInfo.Fields.ContainsKey(MarkupUtilities.GetOriginalBizName(wBm.Name, item.BizName))) { deletedList.Add(wBm.Name); HighLightBookmark(wBm.Name, color); } } } return(deletedList); }
/// <summary> /// highlight bookmark /// </summary> /// <param name="name"></param> public void UnHighLightBookmark(string key) { try { ManagerProfile managerPro = Wkl.MainCtrl.ManagerCtrl.GetProfile(key); Bookmark bm = GetBookmark(managerPro.HighlightBookmarkName); WdColorIndex color = managerPro.WdColorIndex == null ? ProntoMarkup.BackgroundHighLight : managerPro.WdColorIndex; if (bm != null && (bm.Range.HighlightColorIndex == color)) { bm.Range.HighlightColorIndex = ProntoMarkup.BackgroundUnHighLight; } } catch (Exception ex) { ManagerException mgrExp = new ManagerException(ErrorCode.ipe_UnHighlightWordBookmarkError, MessageUtils.Expand(Properties.Resources.ipe_UnHighlightWordBookmarkError, ex.Message), ex.StackTrace); throw mgrExp; } }
/// <summary> /// highlight all bookmarks in docx file /// </summary> /// <param name="wordDoc"></param> private static void HighlightBookmarks(Document wordDoc, Dictionary <string, string> bookmarks, Dictionary <string, string> datatagColors, Dictionary <string, string> documentSpecificColors) { RemoveProtectPassword(wordDoc, ProtectLevel.All); if (bookmarks == null) { return; } foreach (Bookmark bm in wordDoc.Bookmarks) { string name = bm.Name; if (!bookmarks.ContainsKey(name)) { continue; } string domainName = bookmarks[name]; string colorName = string.Empty; WdColorIndex defaultColor = WdColorIndex.wdBlue; if (name.Contains("Sys")) { defaultColor = WdColorIndex.wdBlue; if (documentSpecificColors != null && documentSpecificColors.ContainsKey(domainName)) { colorName = documentSpecificColors[domainName]; } } else { defaultColor = WdColorIndex.wdYellow; if (datatagColors != null && datatagColors.ContainsKey(domainName)) { colorName = datatagColors[domainName]; } } bm.Range.Font.Color = WdColor.wdColorBlack; bm.Range.HighlightColorIndex = GetWdColorIndex(colorName, defaultColor); } }
public void colorDefault(Word.Application myWordApp, WdColorIndex color = WdColorIndex.wdRed) { myWordApp.Selection.Font.ColorIndex = color; }
private void AddTableSegundaSala(List <Tesis> tesisAImprimir, string tabletitle, string tipoTesis, int idInstancia) { List <int> cellWidth; if (idInstancia == 10002) { cellWidth = new List <int>() { 60, 80, 200, 100 } } ; else { cellWidth = new List <int>() { 60, 100, 80, 200 } }; int fila = 1; Range wrdRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range; Table oTable = oDoc.Tables.Add(wrdRng, tesisAImprimir.Count + 3, 4, ref oMissing, ref oMissing); //oTable.Rows[1].HeadingFormat = 1; oTable.Range.ParagraphFormat.SpaceAfter = 6; oTable.Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter; oTable.Range.Font.Size = 9; oTable.Range.Font.Name = "Arial"; oTable.Range.Font.Bold = 0; oTable.Borders.Enable = 1; oTable.Columns[1].SetWidth(cellWidth[0], WdRulerStyle.wdAdjustSameWidth); oTable.Columns[2].SetWidth(cellWidth[1], WdRulerStyle.wdAdjustSameWidth); oTable.Columns[3].SetWidth(cellWidth[2], WdRulerStyle.wdAdjustSameWidth); oTable.Columns[4].SetWidth(cellWidth[3], WdRulerStyle.wdAdjustSameWidth); oTable.Rows[fila].Cells[1].Merge(oTable.Rows[fila].Cells[4]); oTable.Rows[fila].Range.Text = tabletitle; fila++; oTable.Rows[fila].Cells[1].Merge(oTable.Rows[fila].Cells[4]); oTable.Rows[fila].Range.Text = tipoTesis; fila++; if (idInstancia == 10002) { oTable.Cell(fila, 1).Range.Text = "Consecutivo"; oTable.Cell(fila, 2).Range.Text = "Núm. de identificación de la tesis"; oTable.Cell(fila, 3).Range.Text = "Título y subtítulo"; oTable.Cell(fila, 4).Range.Text = "Materia Sugerida por la Sala"; fila++; int consecutivo = 1; foreach (Tesis print in tesisAImprimir) { WdColorIndex cellColor = this.GetCellColor(print.IdColor); oTable.Cell(fila, 1).Range.Text = consecutivo.ToString(); oTable.Cell(fila, 1).Range.Font.ColorIndex = cellColor; oTable.Cell(fila, 2).Range.Text = print.ClaveTesis; oTable.Cell(fila, 2).Range.Font.ColorIndex = cellColor; oTable.Cell(fila, 3).Range.Text = print.Rubro; oTable.Cell(fila, 3).Range.Font.ColorIndex = cellColor; oTable.Cell(fila, 3).Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphJustify; oTable.Cell(fila, 4).Range.Text = print.MateriaAsignada; oTable.Cell(fila, 4).Range.Font.Size = 8; oTable.Cell(fila, 4).Range.Font.ColorIndex = cellColor; fila++; consecutivo++; } } else { oTable.Cell(fila, 1).Range.Text = "Consecutivo"; oTable.Cell(fila, 2).Range.Text = "Órgano"; oTable.Cell(fila, 3).Range.Text = "Núm. de identificación de la tesis"; oTable.Cell(fila, 4).Range.Text = "Título y subtítulo"; fila++; int consecutivo = 1; foreach (Tesis print in tesisAImprimir) { WdColorIndex cellColor = this.GetCellColor(print.IdColor); oTable.Cell(fila, 1).Range.Text = consecutivo.ToString(); oTable.Cell(fila, 1).Range.Font.ColorIndex = cellColor; oTable.Cell(fila, 2).Range.Text = (from n in organismos where n.IdOrganismo == print.IdSubInstancia select n.Organismo).ToList()[0]; oTable.Cell(fila, 2).Range.Font.ColorIndex = cellColor; oTable.Cell(fila, 2).Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphJustify; oTable.Cell(fila, 3).Range.Text = print.ClaveTesis; oTable.Cell(fila, 3).Range.Font.ColorIndex = cellColor; oTable.Cell(fila, 3).Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter; oTable.Cell(fila, 4).Range.Text = print.Rubro; oTable.Cell(fila, 4).Range.Font.Size = 8; oTable.Cell(fila, 4).Range.Font.ColorIndex = cellColor; oTable.Cell(fila, 4).Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphJustify; fila++; consecutivo++; } } }
public DefineColor(string name, WdColorIndex color, Bitmap bitmap) : this(name, color) { Bitmap = bitmap; }
/// <summary> /// 文書の末尾にタイトルを追加する. /// </summary> private static void AddTitle(Word.Application wordApp, ref Word.Document document, String text, WdColorIndex color, Int32 fontSize, WdUnderline underline, Boolean isBold) { if (!String.IsNullOrEmpty(text)) { Int32 before = GetLastPosition(ref document); Word.Range rng = document.Range(document.Content.End - 1, document.Content.End - 1); // テキストを入力 rng.Text += text; Int32 after = GetLastPosition(ref document); // テキストのサイズを設定する document.Range(before, after).Font.Size = fontSize; // テキストに下線を設定する if (underline != WdUnderline.wdUnderlineNone) { document.Range(before, after).Font.Underline = WdUnderline.wdUnderlineSingle; } // テキストの太字を設定する if (isBold) { document.Range(before, after).Font.Bold = -1; } if (color != WdColorIndex.wdNoHighlight) { // テキストを指定した色でマーカーを設定する document.Range(before, after).HighlightColorIndex = color; // 後続の文章にマーカーが適用されないように、末尾をwdNoHighlightに戻す。 document.Range(document.Content.End - 1, document.Content.End - 1).HighlightColorIndex = WdColorIndex.wdNoHighlight; } // 改行を追加 AddParagraph(wordApp, ref document); } }
// 复制Word.Borders的对象到本类 public void clone(Word.Borders obds) { this.AlwaysInFront = obds.AlwaysInFront; // 进行赋值 this.Count = obds.Count; // 进行赋值 this.Creator = obds.Creator; // 进行赋值 try { this.DistanceFrom = obds.DistanceFrom; // 进行赋值 this.DistanceFromBottom = obds.DistanceFromBottom; // 进行赋值 this.DistanceFromLeft = obds.DistanceFromLeft; // 进行赋值 this.DistanceFromRight = obds.DistanceFromRight; // 进行赋值 this.DistanceFromTop = obds.DistanceFromTop; // 进行赋值 } catch (System.Exception ex) { } finally { } this.Enable = obds.Enable; // 进行赋值 this.EnableFirstPageInSection = obds.EnableFirstPageInSection; // 进行赋值 this.EnableOtherPagesInSection = obds.EnableOtherPagesInSection; // 进行赋值 this.HasHorizontal = obds.HasHorizontal; // 进行赋值 this.HasVertical = obds.HasVertical; // 进行赋值 this.InsideColor = obds.InsideColor; // 进行赋值 this.InsideColorIndex = obds.InsideColorIndex; // 进行赋值 this.InsideLineStyle = obds.InsideLineStyle; // 进行赋值 this.InsideLineWidth = obds.InsideLineWidth; // 进行赋值 this.JoinBorders = obds.JoinBorders; // 进行赋值 this.OutsideColor = obds.OutsideColor; // 进行赋值 this.OutsideColorIndex = obds.OutsideColorIndex; // 进行赋值 this.OutsideLineStyle = obds.OutsideLineStyle; // 进行赋值 this.OutsideLineWidth = obds.OutsideLineWidth; // 进行赋值 this.Shadow = obds.Shadow; // 进行赋值 this.SurroundFooter = obds.SurroundFooter; // 进行赋值 this.SurroundHeader = obds.SurroundHeader; // 进行赋值 this.m_hashBorder.Clear(); Border bd = null; // 将Border的各成员进行赋值 for (int i = (int)WdBorderType.wdBorderVertical; i <= (int)WdBorderType.wdBorderTop; i++) { try { bd = (Border)obds[(WdBorderType)i]; } catch (System.Exception ex) { continue; } if (bd != null) { ClassBorder classBd = new ClassBorder(); classBd.clone(bd); m_hashBorder[i] = classBd; } } return; }
public void highlight(Word.Application myWordApp, WdColorIndex color = WdColorIndex.wdDarkYellow) { myWordApp.Selection.Range.HighlightColorIndex = color; }
public DefineColor(string name, WdColorIndex color) : this(name) { Color = color; }
private static WdColorIndex GetWdColorIndex(string colorName, WdColorIndex defaultColor) { if (string.IsNullOrEmpty(colorName)) { return(defaultColor); } switch (colorName.Trim().ToLower()) { case "byauthor": return(WdColorIndex.wdByAuthor); case "auto": return(WdColorIndex.wdAuto); case "nohighlight": return(WdColorIndex.wdNoHighlight); case "black": return(WdColorIndex.wdBlack); case "blue": return(WdColorIndex.wdBlue); case "turquoise": return(WdColorIndex.wdTurquoise); case "brightgreen": return(WdColorIndex.wdBrightGreen); case "pink": return(WdColorIndex.wdPink); case "red": return(WdColorIndex.wdRed); case "yellow": return(WdColorIndex.wdYellow); case "white": return(WdColorIndex.wdWhite); case "darkblue": return(WdColorIndex.wdDarkBlue); case "teal": return(WdColorIndex.wdTeal); case "green": return(WdColorIndex.wdGreen); case "violet": return(WdColorIndex.wdViolet); case "darkred": return(WdColorIndex.wdDarkRed); case "darkyellow": return(WdColorIndex.wdDarkYellow); case "gray50": return(WdColorIndex.wdGray50); case "gray25": return(WdColorIndex.wdGray25); default: return(defaultColor); } }
public static void AddPAragraph(Paragraph paragraph, string text, int spaceBefore, int spaceAfter, int flagFontBold, int fontSize, WdParagraphAlignment paragraphAlignment, WdColorIndex highlightColor = WdColorIndex.wdAuto) { paragraph.Range.Text = text; paragraph.Format.SpaceBefore = spaceBefore; paragraph.Format.SpaceAfter = spaceAfter; paragraph.Range.Font.Bold = flagFontBold; paragraph.Range.Font.Size = fontSize; paragraph.Range.HighlightColorIndex = highlightColor; paragraph.Format.Alignment = paragraphAlignment; paragraph.Range.InsertParagraphAfter(); }