How to Add Paragraph Breaks at Wrapped Lines in Word Using a VBA Macro
Question details
The user needs to insert hard paragraph marks at the end of every visually wrapped line in a Word document so that the line structures are retained when pasted into other applications.

- Product
- Microsoft Word
- Device & OS
- not provided
- Scenario
- Preparing a document for export or use in another application that does not recognize Word's visual margins or automatic line wrapping.
- Observed behavior
- Word visually wraps lines to fit the page margins without adding actual paragraph breaks, causing the text to lose its visual structure when transferred to plain text editors or unsupported apps.
Since this VBA macro permanently alters the structural layout of your text, always save a backup copy of your original document before running the code.
Use a Custom VBA Macro to Insert Paragraph Breaks
Run a VBA script that navigates your document line by line and inserts a carriage return at the end of each wrapped line, while skipping tables and images.
This approach automates the tedious process of manually pressing Enter at the end of every visual line. The macro uses Word's built-in line navigation properties to detect where a line ends visually based on your current margin settings, and inserts a hard break accordingly.
Open your Microsoft Word document and press Alt + F11 to launch the Visual Basic for Applications (VBA) Editor.
Click 'Insert' from the top menu bar and select 'Module' to create a new blank workspace for your code.
Paste your specialized VBA routine designed to move through the document line by line and insert paragraph marks (^p) at line ends. Ensure the script includes logic to skip blank lines, tables, and inline objects.
Close the VBA Editor, return to Word, and press Alt + F8 to open the Macros dialog box. Select your newly created macro and click 'Run'.

Try WPS Office for Seamless Document Editing and Formatting
If you frequently struggle with complex formatting rules or VBA macros in Microsoft Word, consider switching to WPS Office. It provides a lightweight, highly compatible word processor that makes layout adjustments easy without relying heavily on custom scripting.
- 1. Download WPS Office: Visit the official WPS Office website and download the free installer for your operating system.
- 2. Install the application: Run the setup file and follow the straightforward on-screen instructions to complete the installation.
- 3. Open your document: Launch WPS Writer and open your existing Word document to experience seamless editing and robust formatting tools.

Frequently Asked Questions
Why does text lose its line breaks when pasted into another program?
Word processors like Microsoft Word wrap text visually based on page margins. They do not insert actual paragraph or line break characters at the end of each line, so plain text editors read it as one continuous, uninterrupted paragraph.
Can I undo the macro after it inserts paragraph breaks?
If you just ran the macro, you can usually press Ctrl + Z to undo the changes. However, for large documents, Word might clear the undo history to save memory, which is why working on a backup copy is crucial.
Will the VBA macro affect my tables and images?
A well-written line-break VBA macro includes conditional logic to skip blank lines, tables, shapes, and inline objects to avoid corrupting the document layout.
Is there a non-macro way to replace wrapped lines with hard breaks?
There is no built-in native button in Word to convert visual line wraps to hard paragraph returns automatically. Without a VBA macro, you must manually click at the end of each visual line and press Enter.




