I am using VSTO SE, and I'm adding multiple content controls to a page on a ribbon button click event. When I add just one contentcontrol, I can begin typing in the control, hit enter and it will go to the next line. However, when I add 2 controls, both controls will not allow me to go to the next line by hitting the enter key. Here's my code:
object missing = Type.Missing;
object moveUnit = WdUnits.wdCharacter;
object moveLength = 1;
object startRange, endRange;
Range range = p_Application.Selection.Range;
range.Paragraphs.Alignment = WdParagraphAlignment.wdAlignParagraphLeft;
startRange = range.Start;
ContentControl cc1 = p_Application.Selection.Range.ContentControls.Add(WdContentControlType.wdContentControlRichText, ref missing);
cc1.Title = "ContentControl1";
p_Application.Selection.TypeText("ContentControl1");
p_Application.Selection.MoveRight(ref moveUnit, ref moveLength, ref missing);
ContentControl cc2 = p_Application.Selection.Range.ContentControls.Add(WdContentControlType.wdContentControlRichText, ref missing);
cc2.Title = "ContentControl2";
cc2.Range.ParagraphFormat.SpaceBefore = 0;
cc2.Range.ParagraphFormat.SpaceAfter = 0;
cc2.Range.ParagraphFormat.LineSpacingRule = WdLineSpacing.wdLineSpaceSingle;
cc2.SetPlaceholderText(null, null, "ContentControl2");
Does anyone have an idea why this might be happening
Thanks in advance,
Drew Hysong