Formatting Issues

Fix Text File Line and Paragraph Breaks in Microsoft Word

John WilsonJohn Wilson Nov 27, 2026 870 views

Question details

Import a text file into Word automatically while preserving its intended line and paragraph breaks.

How to Import Text Files with Correct Breaks in Microsoft Word
Product
Microsoft Word for Microsoft 365
Device & OS
not provided
Scenario
A text file contains hexadecimal 0B line breaks and 0D paragraph breaks and must be opened or inserted without manual copying and pasting.
Observed behavior
Word displays the breaks incorrectly when the file is opened or inserted with an INCLUDETEXT field, although manual copy and paste displays them correctly.
Before you start

Check the text file's encoding and confirm that 0B represents a manual line break and 0D represents a paragraph break. Test the import with a small sample containing both types of breaks.

Solution 1Recommended

Convert the control characters with a Word VBA import macro

Use this approach in desktop Word on Windows when the file encoding is known and an automated import is needed.

The example reads a UTF-8 file, inserts a Word manual line break for each 0B character, and inserts a paragraph mark for each 0D character. It also treats CRLF as one paragraph break and a standalone LF as a paragraph break.

This imports static text at the insertion point; it does not create an INCLUDETEXT field or automatically refresh when the source file changes. Adapt the file selection and encoding to your workflow.

1
Open the VBA editor

In desktop Word on Windows, press Alt+F11, select Insert > Module, and paste the macro below into the module.

2
Add the import macro

Paste this code: Sub ImportTextWithBreaks() Dim picker As FileDialog Dim stream As Object Dim text As String, chunk As String, ch As String Dim i As Long Set picker = Application.FileDialog(msoFileDialogFilePicker) picker.Title = "Select a text file" picker.Filters.Clear picker.Filters.Add "Text files", "*.txt" If picker.Show <> -1 Then Exit Sub Set stream = CreateObject("ADODB.Stream") stream.Type = 2 stream.Charset = "utf-8" stream.Open stream.LoadFromFile picker.SelectedItems(1) text = stream.ReadText stream.Close For i = 1 To Len(text) ch = Mid$(text, i, 1) If ch = Chr$(11) Or ch = vbCr Or ch = vbLf Then If Len(chunk) > 0 Then Selection.TypeText Text:=chunk chunk = "" If ch = Chr$(11) Then Selection.InsertBreak Type:=wdLineBreak Else Selection.TypeParagraph If ch = vbCr And i < Len(text) Then If Mid$(text, i + 1, 1) = vbLf Then i = i + 1 End If End If Else chunk = chunk & ch End If Next i If Len(chunk) > 0 Then Selection.TypeText Text:=chunk End Sub

3
Set the encoding

In the module, check the stream.Charset line. Leave it as "utf-8" for a UTF-8 source file, or change it to a charset supported by ADODB.Stream that matches the file's actual encoding.

4
Run and check the import

Place the cursor where the text should be inserted, press Alt+F8, select ImportTextWithBreaks, and click Run. Choose the text file, then use Home > ¶ to inspect the resulting line and paragraph marks.

Convert the control characters with a Word VBA import macro
Macro availability: The example uses Windows ADODB.Stream and requires macros to be permitted by your Word security settings. Re-run the macro when the source changes, or adapt it to replace the previously imported content.
Free Microsoft Office alternative

Edit Word-Compatible Documents with WPS Writer

WPS Office is a free, lightweight alternative with a familiar interface for editing documents. Its Microsoft Office format compatibility makes it easy to move existing files into WPS Writer, though it does not fix Word's INCLUDETEXT import behavior.

Open and edit documents in a familiar word-processing interfaceWork with Microsoft Word formats such as DOC and DOCXReview and adjust document formatting after importing textMove existing Office documents into a lightweight suite
microsoft office alternative - wps office

Frequently Asked Questions

Why does copying and pasting show different breaks from opening the text file?

Word can interpret control characters differently depending on whether text is pasted, opened, or inserted through a field. Check the source encoding and the actual characters in a sample file before choosing a conversion method.

How can I see whether Word inserted a line break or a paragraph mark?

On the Home tab, click ¶ in the Paragraph group to show formatting marks. Manual line breaks and paragraph marks appear with different symbols.

Will the VBA import update automatically when the text file changes?

No. The example inserts static text rather than an INCLUDETEXT field. Run the macro again or adapt it to replace the previous import as part of your automated workflow.

What should I do if the imported characters are garbled?

Verify the source file's encoding, then change the stream.Charset value in the macro to a matching ADODB.Stream-supported charset. Test with a short sample before importing the full file.