Alice
Alice

Reputation: 201

Word 2010 Content Controls New Line

I am populating 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

Upvotes: 1

Views: 5312

Answers (3)

Robert
Robert

Reputation: 1631

If you are using VBA, what you are searching for is

vbNewLine

which will insert a full line break.

Upvotes: 0

Bim
Bim

Reputation: 21

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;

        }

Upvotes: 0

Todd Main
Todd Main

Reputation: 29153

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

Upvotes: 3

Related Questions