Word 365 Write a Book add Programming language code blocks

Anonymous
2020-04-21T06:04:36+00:00

I have Office 365 Home - in Word 365 I plan to Write a Docx document for future converting in PDF E-book

The eBook should include programming code

in Python, Javascript, PHP, Java, and C++

When adding the programming language code sections... how can color for the code, in other words, code be like the screenshot below for example???

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes

8 answers

Sort by: Most helpful
  1. Anonymous
    2020-06-19T17:41:44+00:00

    In Word, use a particular paragraph style for your code examples. Add paragraph shading to that style.

    Also, enable Line Numbering as required. You will have to suppress it for other styles in the document.

    how to

    Also, enable Line Numbering as required.

    ?????

    0 comments No comments
  2. Stefan Blom 324.4K Reputation points MVP Volunteer Moderator
    2020-06-19T18:27:10+00:00

    Line Numbering is on the Layout tab in Word:

    0 comments No comments
  3. Anonymous
    2020-06-20T03:40:15+00:00

    Thank you for replying I opened a new embedded word document to make a code block according to:

    To address your concerns, use the instructions below.

    1. Go to insert tab
    2. Click object on the right part of the ribbon.
    3. Choose OpenDocument Text which will open a new embedded word document
    4. Copy and paste your code.
    5. Save and close.

    I applied for line numbers in a new embedded word document, but when saved and returned to origin doc the line numbers Do Not seem in the doc - the block of code is without line numbers, well?

    0 comments No comments