Put html in word

How to Insert Source Code Into a Word Document

Martin Hendrikx is a former Lifewire writer and an instructor with a background in technology whose work has been published by How-To Geek and other outlets.

Ryan Perian is a certified IT specialist who holds numerous IT certifications and has 12+ years’ experience working in the IT industry support and management positions.

In This Article

What to Know

  • To embed a second document into a Word document: Insert >Object >Create New >Word Document > clear Display as icon >OK.
  • You can also use Paste Special to insert a variety of data into a document, including code.

This article explains issues with using source code in Word for Microsoft 365, Word 2019, Word 2016, Word 2013, Word 2010, and Word 2007 and instructions for embedding a second document in a Word file. It also provides information on pasting other data into a Word document.

The Problem With Using Source Code in Word

Programmers write software programs using languages such as Java, C++, and HTML. Programming languages use different formatting and symbols from regular languages, so pasting a snippet of code into Word from a programming application causes errors such as text reformatting, indentation shifts, link creation, and misspellings.

Given how Microsoft Word structures documents, inserting and working with source code is more difficult than working in a dedicated code editor. However, document embeds create a container that protects source code from being reformatted.

One way to avoid these formatting issues is to paste the source code into a separate document within the main Word document.

Embed a Second Document Into a Word Document

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

These instructions only work with a single page of code.

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

A Word document with the Insert field highlighted

Select Insert.

A Word document with the Object option highlighted in the Insert menu

In the Text group, select Object.

Object dialogue box with the Create New tab highlighted in Word

In the Object dialog box, select the Create New tab.

Create New Object box in Word with the Microsoft Word Document option highlighted

In the Object type list, Select Microsoft Word Document.

Create New Object window in Word with the Display as icon box highlighted

Clear the Display as icon check box.

Create New Object window in Word with the OK button highlighted

Select OK.

Microsoft Word displaying source code to insert into a Word presentation document

Copy and paste the source code into the new document. Word automatically ignores the spaces, tabs, and other formatting problems. Spelling errors and grammatical errors are highlighted in the document, but these errors are ignored when the code is inserted in the original document.

Microsoft Word document with source code inserted

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

Using Different Paste Types in Word

The most up-to-date versions of Word handle code better than they used to. Word for Microsoft 365 supports several forms of pasting, including with and without source formatting. So pasting a block of code from, for example, Microsoft Visual Studio Code will look different based on the paste type. If you select Paste Special, each of the three options yields a different result:

  • Unformatted Text: All code is pasted as unformatted, so you’ll lose indenting, color, typeface, and related contextual clues.
  • HTML Format: From VSC, a paste-as-HTML renders what appears to be a photo of the code, complete with the text editor’s background color. This code block is editable, and you can remove the background color in the Paragraph Fill menu option.
  • Unformatted Unicode Text: Pastes the text as is but strips the text and background colors. Re-format the code as needed.

To see formatting marks and codes in Word temporarily, go to Home and select the Show/Hide icon to toggle marks on and off. To keep them on permanently, go to File > Options > Display > Show all formatting marks > OK.

To add a link in a Word document, highlight the text you want to hyperlink, right-click it, and select Link. Alternatively, select Insert > Links > Link and enter the URL.

To convert a Word document to HTML, go to File > Save As. Under Save as Type, choose .html. You can also use an editor like Dreamweaver.

Источник

How to create and modify an HTML document in Word 2003

To create your new HTML document, use one of the following two methods.

Method 1

  1. Start Word 2003.
  2. In the New Document task pane, click
    Web Page under New.
  3. Click File, and then click
    Save.

Method 2

  1. Start Word 2003.
  2. Click File, and then click Save as Web Page.
  3. In the File name box, type the file name that you want for your document, and then click Save.
  1. Open the HTML document that you created earlier in this article. To do this, follow these steps:
    1. Click File, and then click
      Open.
    2. Locate your saved article, in the «Create Your HTML Document» section of this article.
    3. Click the file, and then click Open.

    Add an Image to Your HTML Document

    1. Put your insertion point where you want the image to be in your document.
    2. Click Insert, point to
      Picture, and then click ClipArt.
    3. In the ClipArt task pane, click
      Search.

    Open an HTML Document in Word

    1. Click File, and then click
      Open.
    2. In the Open dialog box, locate the HTML document that you created earlier, and then select it.
    3. Click Open.

    References

    For more information about HTML support in Word 2003, follow these steps:

    1. Start Word 2003.
    2. On the Help menu, click Microsoft Word Help.
    3. Type HTML in the
      Search box, and then click the arrow.
    4. Related topics and templates will appear.

    Источник

    HOW TO: Create and Edit an HTML Document with Microsoft Word 2002

    This article provides a step-by-step guide to how to create an HTML document, including items such as typing text and adding images and hyperlinks to your HTML document.

    Create Your HTML Document

    Use one of the following two methods to create your new HTML document.

    Method 1

    1. Start Microsoft Word.
    2. In the New Document task pane, click Blank Web Page under New.
    3. On the File menu, click Save.

    Method 2

    1. Start Microsoft Word.
    2. Create a new blank document.
    3. On the File menu, click Save as Web Page.
    4. In the File name box, type the file name that you want for your document, and then click Save.
    1. Open the HTML document that you created earlier in this article. To do this, follow these steps:
      1. On the File menu, click Open.
      2. Browse to the location that you saved your article to, in the «Create Your HTML Document» section of this article.
      3. Select the file and then click Open.

      Add an Image to Your HTML Document

      1. Place your insertion point where you want to place an image in your document.
      2. On the Insert menu, point to Picture, and then click ClipArt.
      3. In the Insert ClipArt task pane, click Search.

      Open an HTML Document in Word

      If the New Document task pane is still displayed:

      In the New Document task pane, select the document under Open a document. This opens the document directly.

      If the New Document task pane is not displayed:

      1. On the File menu, click Open.
      2. In the Open dialog box, locate the HTML document that you created earlier, and then select it.
      3. Click Open.

      REFERENCES

      For more information about HTML support in Word 2002, follow these steps:

      1. Open Microsoft Word 2002.
      2. On the Help menu, click Microsoft Word Help.
      3. Click the Answer Wizard tab.
      4. Type HTML in the What would you like to do? box, and then click Search.
      5. Related topics will be displayed. Click any item to display the information.

      Источник

      How to Insert Source Code Into a Word Document

      Martin Hendrikx is a former Lifewire writer and an instructor with a background in technology whose work has been published by How-To Geek and other outlets.

      Ryan Perian is a certified IT specialist who holds numerous IT certifications and has 12+ years’ experience working in the IT industry support and management positions.

      In This Article

      What to Know

      • To embed a second document into a Word document: Insert >Object >Create New >Word Document > clear Display as icon >OK.
      • You can also use Paste Special to insert a variety of data into a document, including code.

      This article explains issues with using source code in Word for Microsoft 365, Word 2019, Word 2016, Word 2013, Word 2010, and Word 2007 and instructions for embedding a second document in a Word file. It also provides information on pasting other data into a Word document.

      The Problem With Using Source Code in Word

      Programmers write software programs using languages such as Java, C++, and HTML. Programming languages use different formatting and symbols from regular languages, so pasting a snippet of code into Word from a programming application causes errors such as text reformatting, indentation shifts, link creation, and misspellings.

      Given how Microsoft Word structures documents, inserting and working with source code is more difficult than working in a dedicated code editor. However, document embeds create a container that protects source code from being reformatted.

      One way to avoid these formatting issues is to paste the source code into a separate document within the main Word document.

      Embed a Second Document Into a Word Document

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

      These instructions only work with a single page of code.

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

      A Word document with the Insert field highlighted

      Select Insert.

      A Word document with the Object option highlighted in the Insert menu

      In the Text group, select Object.

      Object dialogue box with the Create New tab highlighted in Word

      In the Object dialog box, select the Create New tab.

      Create New Object box in Word with the Microsoft Word Document option highlighted

      In the Object type list, Select Microsoft Word Document.

      Create New Object window in Word with the Display as icon box highlighted

      Clear the Display as icon check box.

      Create New Object window in Word with the OK button highlighted

      Select OK.

      Microsoft Word displaying source code to insert into a Word presentation document

      Copy and paste the source code into the new document. Word automatically ignores the spaces, tabs, and other formatting problems. Spelling errors and grammatical errors are highlighted in the document, but these errors are ignored when the code is inserted in the original document.

      Microsoft Word document with source code inserted

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

      Using Different Paste Types in Word

      The most up-to-date versions of Word handle code better than they used to. Word for Microsoft 365 supports several forms of pasting, including with and without source formatting. So pasting a block of code from, for example, Microsoft Visual Studio Code will look different based on the paste type. If you select Paste Special, each of the three options yields a different result:

      • Unformatted Text: All code is pasted as unformatted, so you’ll lose indenting, color, typeface, and related contextual clues.
      • HTML Format: From VSC, a paste-as-HTML renders what appears to be a photo of the code, complete with the text editor’s background color. This code block is editable, and you can remove the background color in the Paragraph Fill menu option.
      • Unformatted Unicode Text: Pastes the text as is but strips the text and background colors. Re-format the code as needed.

      To see formatting marks and codes in Word temporarily, go to Home and select the Show/Hide icon to toggle marks on and off. To keep them on permanently, go to File > Options > Display > Show all formatting marks > OK.

      To add a link in a Word document, highlight the text you want to hyperlink, right-click it, and select Link. Alternatively, select Insert > Links > Link and enter the URL.

      To convert a Word document to HTML, go to File > Save As. Under Save as Type, choose .html. You can also use an editor like Dreamweaver.

      Источник

      Читайте также:  How to change ip address in python
Оцените статью