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-04-21T06:11:57+00:00

    Hi! This is King, an Independent Advisor, I am a fellow Microsoft customer and expert user here to help.

    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.

    You may refer to the link below where I got the exact instructions from stackoverflow.

    https://stackoverflow.com/questions/387453/how-...

    I hope this will help you to resolve your concerns. Please don't hesitate to reply if still have some follow-up concerns.

    Regards,
    -King

    Note: This is a non-Microsoft website. The page appears to be providing accurate, safe information. Watch out for ads on the site that may advertise products frequently classified as a PUP (Potentially Unwanted Products). Thoroughly research any product advertised on the site before you decide to download and install it.

    1 person found this answer helpful.
    0 comments No comments
  2. Anonymous
    2020-04-21T08:25:01+00:00

    Thank you for your reply

    When pasting the code eg from VS Code editor

    You recommend from Paste Options choose - first icon

    Keep source formating

    to keep the colors/highlight of code snippet... this is the most common?

    1 person found this answer helpful.
    0 comments No comments
  3. Anonymous
    2020-04-22T01:36:21+00:00

    Yes. With the use of keep source formatting, coding formats will be followed when you paste the text.

    I hope this will help you.

    Regards,
    King

    0 comments No comments
  4. Anonymous
    2020-06-19T09:44:44+00:00

    How to Add line numbers to Code block [ OpenDocument Text which will open a new embedded word document ] in Word 365...?

    0 comments No comments
  5. Stefan Blom 324.2K Reputation points MVP Volunteer Moderator
    2020-06-19T12:44:05+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.

    1 person found this answer helpful.
    0 comments No comments