logo
search
Formatting Issues

How to Insert Multi-Page Code with Syntax Highlighting in Word

Natalie TaylorNatalie Taylor Oct 13, 2026 873 views

Question details

The user wants to insert multiple pages of source code into a Word document while retaining the original formatting, syntax highlighting, and editability.

How to Insert Multi-Page Code with Syntax Highlighting in Word
Product
Microsoft Word
Device & OS
not provided
Scenario
Writing technical documentation, reports, or manuals that require long snippets of readable programming scripts.
Observed behavior
Standard pasting removes syntax highlighting, triggers disruptive spelling and grammar errors, and often fails to maintain clean multi-page alignment.
Before you start

Ensure you have your original source code open in an advanced text editor like Notepad++ or Visual Studio Code, as these tools help format and prepare the syntax highlighting before transferring to Word.

Solution 1Recommended

Paste Code as Formatted RTF from a Text Editor

This is the most reliable method to keep original syntax highlighting, colors, and multi-page flow without needing extra Word add-ins.

Advanced text editors have built-in features to export code along with its visual formatting as Rich Text Format (RTF). When this RTF is pasted into Word, it translates perfectly into standard text with all colors and line breaks intact.

1
Open your code editor

Launch an editor like Notepad++. Ensure your code is properly recognized and highlighted according to its programming language.

2
Copy as RTF

In Notepad++, navigate to 'Plugins' > 'NppExport' and select 'Copy RTF to clipboard'. In other editors like VS Code, copying the text naturally copies the RTF data by default.

3
Paste into Word

Open your Microsoft Word document. Right-click the destination area and choose 'Keep Source Formatting' under the Paste Options.

4
Adjust layout

Verify that the text flows correctly across multiple pages. The code is fully editable and searchable.

Paste Code as Formatted RTF from a Text Editor
Quick Tip: If your code spans many pages, adjusting the paragraph line spacing to 'Single' and removing space after paragraphs can make it look much cleaner.

Format Technical Documents Effortlessly with WPS Writer

WPS Writer provides robust styling options and flawless RTF pasting capabilities, making it incredibly easy to include multi-page, syntax-highlighted code in your technical reports and documentation.

  1. 1. Copy your code: Highlight and copy your source code from your preferred code editor, ensuring it copies the rich text formatting.
  2. 2. Open WPS Writer: Launch WPS Office and open your existing document or create a new technical report.
  3. 3. Paste with original formatting: Right-click in the document, select 'Keep Source Formatting', and watch your colorful, highlighted code appear perfectly.
  4. 4. Customize paragraph settings: Select the code block and adjust spacing or proofing language within WPS Writer's intuitive sidebar to finalize your layout.
Seamless format compatibility with Microsoft Word (.docx) documentsAccurate RTF pasting from editors like Notepad++ and VS Code to preserve syntax colorsHighly customizable text styles to easily disable spell-check for programming code blocksLightweight, fast-loading, and free-to-use application for all your word processing needs
microsoft office alternative - wps office

Frequently Asked Questions

Why does my source code have red underlines in Word?

Microsoft Word treats programming syntax and variables as misspelled words. You can fix this by highlighting the code, going to Review > Language > Set Proofing Language, and checking 'Do not check spelling or grammar'.

Can I insert code as an object to keep its formatting intact?

Yes, you can go to Insert > Object and choose an OpenDocument Text object. However, embedded objects typically cannot flow across multiple pages, meaning long snippets of code will be cut off at the bottom of the page.

Should I just use screenshots for my code?

While taking a screenshot guarantees the formatting looks perfect, it is not recommended for multi-page code. Images cannot be edited later, are not searchable within the document, and are inaccessible to screen readers.

What is the best font for displaying code in a document?

Monospaced fonts are the standard for code because every character takes up the exact same width, maintaining proper indentation. Popular choices include Consolas, Courier New, Lucida Console, and Cascadia Code.