XML – adding new line

calendar_today Asked Nov 7, 2012
thumb_up 19 upvotes
history Updated April 14, 2026

Direct Answer

Use the <w:br/> tag. I found it by creating a Word document, saving it as XML (via Save As), adding a forced line break with Shift Enter, and checked out the change. The…. This is a prose walkthrough, ranked #3rd of 32 by community upvote score, from 2012.


The Problem (Q-score 7, ranked #3rd of 32 in the Word VBA archive)

The scenario as originally posted in 2012

I have MS word doc saved as .docx. I want to insert new line in my text by edditing XML file of docx. I have already tried &#xA;, &#13;, &#10;, &#x9;, amd it always gives me only space not a new line.

what it does:

(XML code)
<w:t>hel&#xA;lo</w:t>

When I open .docx file then it is changed to:

Hel lo not as I wanted to be Hel on one line and lo on secound line.

Why community consensus is tight on this one

Across 32 Word VBA entries in the archive, the accepted answer here holds elite answer (top 10 %%) status — meaning voters are unusually aligned on the right fix.


The Verified Solution — elite answer (top 10 %%) (+19)

Verbal answer — walkthrough without a code block

Note: the verified answer is a prose walkthrough. If you need a runnable sample, check Word VBA entries ranked in the top 10 of the same archive.

Use the <w:br/> tag.

I found it by creating a Word document, saving it as XML (via Save As), adding a forced line break with Shift Enter, and checked out the change. The essential difference seems to be just the w:br tag, apparently reflecting the HTML br tag.


When to Use It — vintage (14+ years old, pre-2013)

A top-10 Word VBA pattern — why it still holds up

Ranks #3rd of 32 in the Word VBA archive. The only pattern ranked immediately above it is “Why does the file utility identify Microsoft Word files as CDF? What…” — compare both if you’re choosing between approaches.

What changed between 2012 and 2026

The answer is 14 years old. The Word VBA object model has been stable across Office 2013, 2016, 2019, 2021, 365, and 2024/2026 LTSC, so the pattern still compiles. Changes that might affect you: 64-bit API declarations (use PtrSafe), blocked macros in downloaded files (Mark-of-the-Web), and the shift toward Office Scripts for web-first workflows.

help
Frequently Asked Questions

Why is this answer the top decile of Word VBA Q&A?
expand_more

Answer score +19 vs the Word VBA archive median ~6; this entry is elite. The score plus 7 supporting upvotes on the question itself (+7) means the asker and 18 subsequent voters all validated the approach.

The answer has no code block — how do I turn it into a snippet?
expand_more

Use the walkthrough above as a checklist, then open a top-10 Word VBA archive entry for a concrete starting template you can adapt.

This answer is 14 years old. Is it still relevant in 2026?
expand_more

Published 2012, which is 14 year(s) before today’s Office 2026 build. The Word VBA object model has had no breaking changes in that window. Three things to re-test: (1) blocked macros on downloaded files (Mark-of-the-Web), (2) 64-bit API declarations (PtrSafe, LongPtr), (3) any shift toward Office Scripts for web scenarios.

Which Word VBA pattern ranks just above this one at #2?
expand_more

The pattern one rank above is “Why does the file utility identify Microsoft Word files as CDF? What is this CDF?”. If your use case overlaps, compare both before committing.

Data source: Community-verified Q&A snapshot. Q-score 7, Answer-score 19, original post 2012, ranked #3rd of 32 in the Word VBA archive. Last regenerated April 14, 2026.