Word 2010 Content Controls New Line
I am populating 开发者_StackOverflow中文版a content control in word 2010 with some text. I can't get my text to go on a new line. I have tried '\n' ,'\r', Environment.NewLine and it still appears on one line.
Any ideas what I should be using
I believe you may need to enable MultiLine = True
for the CC. See: http://msdn.microsoft.com/en-us/library/microsoft.office.tools.word.contentcontrol.multiline(v=VS.90).aspx
If you've already done that, see Microsoft Word Document Controls not accepting carriage returns for a possible solution
You could use something like this:
private static Run InsertFormatRun(Run run, string[] formatText)
{
foreach (string text in formatText)
{
run.AppendChild(new Text(text));
RunProperties runProps = run.AppendChild(new RunProperties());
Break linebreak = new Break();
runProps.AppendChild(linebreak);
}
return run;
}
If you are using VBA, what you are searching for is
vbNewLine
which will insert a full line break.
精彩评论