1

My code creates a 1 column, 2-row table.

Then, my code manipulates the existing rows. My goal is to select the two rows and do the equivalent of these manual commands in Word: Home -> Paragraph -> Line and Page breaks -> Keep Lines Together

The problem is that Paragraphs p = wordApp.Selection.Paragraphs; returns no paragraphs

What Word Interop object to I need to obtain and manipulate in order to apply keep lines together to my selection?

currentRow = imagesTable.Rows.First;

Cell ulCell = currentRow.Cells[1];

// Code to load cell with text

currentRow = currentRow.Next;

// Insert image
currentRow.Height = wordApp.InchesToPoints(5.5F);
currentRow.Cells[1].Select();

InlineShape inlineShape = wordApp.Selection.InlineShapes.AddPicture(imageAttachment.P_AttachmentFqfn);
inlineShape.LockAspectRatio = Microsoft.Office.Core.MsoTriState.msoTrue;
inlineShape.Height = wordApp.InchesToPoints(3F);

Cell lrCell = currentRow.Cells[1];

document.Range(ulCell.Range.Start, lrCell.Range.End).Select();

Paragraphs p = wordApp.Selection.Paragraphs;
p.KeepTogether = 1;
p.KeepWithNext = 1;
VA systems engineer
  • 2,856
  • 2
  • 14
  • 38

0 Answers0