How to Use Word VBA Macros to Remove Line Breaks and Reformat Images
Question details
The user wants to create or troubleshoot a Word VBA macro to reliably remove manual line breaks and paragraph marks without negatively impacting image layouts and document formatting.

- Product
- Word
- Device & OS
- not provided
- Scenario
- Reformatting a document heavily reliant on manual line breaks and empty paragraphs using VBA macros.
- Observed behavior
- Standard Find and Replace macros are removing unintended breaks because Word uses different character codes for paragraph marks and line breaks, and hidden spaces prevent empty paragraphs from being deleted.
Before running any VBA macro, always test it on a duplicate copy of your document to prevent unintended cascading replacements that could alter essential text formatting or image anchors.
Differentiate Paragraph Marks (^13) and Manual Line Breaks (^11)
Modify your VBA macro to search for paragraph marks and manual line breaks separately using their specific character codes.
Word treats manual line breaks (inserted via Shift+Enter) differently than standard paragraph marks (inserted via Enter). Addressing them individually in your macro ensures precise text manipulation.
You can combine this with wildcard searches in VBA to match the specific characters immediately preceding the intended breaks.
In your VBA editor or Find and Replace dialog, use ^13 to target standard paragraph marks and ^11 to target manual line breaks.
Set up your macro to execute two separate Find and Replace operations: one that searches for ^11 and replaces it with a space, and another that targets ^13 where necessary.
If you need to preserve characters before the break, ensure your macro sets 'MatchWildcards = True' so you can use pattern matching to skip or include preceding text.

Clear Hidden Content Before Running the Macro
Remove trailing spaces, tabs, and hidden characters from empty paragraphs so the macro can successfully delete them.
Easily Remove Line Breaks in WPS Writer Without Macros
WPS Writer provides a powerful, built-in Find and Replace tool with full wildcard and special character support. You can easily clean up line breaks and empty paragraphs visually without needing to write or debug complex VBA code.
- 1. Open the Find and Replace dialog: Open your document in WPS Writer and press Ctrl + H on your keyboard to launch the Replace tab.
- 2. Select the special character: Click the 'Special' button at the bottom of the dialog. From the list, select 'Manual Line Break' (^l) or 'Paragraph Mark' (^p) depending on what you want to remove.
- 3. Set the replacement criteria: Leave the 'Replace with' field blank if you want to delete the breaks entirely, or type a single space if you want to join the lines together.
- 4. Execute the replacement: Click 'Replace All' to instantly format your document. WPS Writer will notify you how many replacements were made.

Frequently Asked Questions
What is the difference between ^13 and ^11 in Word macros?
In Word VBA, ^13 represents a standard paragraph mark (created by pressing Enter), which controls paragraph-level formatting. ^11 represents a manual line break (created by pressing Shift+Enter), which forces text to a new line without starting a new paragraph.
Why is my VBA macro failing to delete empty paragraphs?
Empty paragraphs often contain hidden formatting characters, such as trailing spaces or tabs, which prevent the macro from recognizing the paragraph as 'empty'. You must program the macro to search for and clear these hidden spaces before attempting to delete the paragraph mark.
How do I prevent my Find and Replace macro from altering image positions?
Images in Word are often anchored to specific paragraph marks. If a global wildcard replacement accidentally targets the paragraph mark anchoring an image, the image layout will break. Account for indentation and cascading paragraphs in your VBA code, and avoid blanket deletions of all ^13 characters.




