How to Paste the Source Code in a Word Document

Content
  1. This can be done without snapshots of each segment
  2. Problem with source code in Word
  3. Insert a second document into a Word document

This can be done without snapshots of each segment

If you are a programmer or software developer, you may find it difficult to use Microsoft Word to work with source code. There is a way to paste the source code into a Word document without taking pictures of each code segment.

The instructions in this article apply to Word 2019, 2016, 2013, 2010, 2007; and Word for Office 365.

Problem with source code in Word

Programmers write programs in languages ​​such as Java, C++ and HTML. They use different formatting and characters from common languages, so pasting a code snippet into Word from a programming application results in errors such as text reformatting, indentation, link building, and spelling errors.

One way to avoid these formatting issues is to paste the source code into a separate document that appears in your main Word document.

Insert a second document into a Word document

Here’s how to paste the source code into a Word document using a second embedded document.

These instructions only work with one page of code.

  1. Open the target document in Microsoft Word and place the cursor where the source code appears.

  2. Go to Insert

  3. In Group Text select An object

  4. In the dialog box An object select tab Create new

  5. mention Object type select Microsoft Word Document † Select in Word 2007 Open document text

  6. Uncheck the box Show as icon

  7. Select Okay

  8. A new document will open with the name document in [ имя файла целевого документа ] † Save the document in the same folder as the target document.

  9. Copy and paste the source code into a new document. Word automatically ignores all spaces, tabs, and other formatting issues. Spelling and grammatical errors are flagged in the document, but when the code is pasted into the original document, those errors are ignored.

  10. Save and close the source document. The source code appears in the main document.

  11. Resume work on the master document.

Leave a Reply

Your email address will not be published.