Skip to content

Latest commit

 

History

History
51 lines (40 loc) · 2.59 KB

how-to-programmatically-add-text-and-formatting-to-cells-in-word-tables.md

File metadata and controls

51 lines (40 loc) · 2.59 KB
title description titleSuffix ms.date ms.topic dev_langs helpviewer_keywords author ms.author manager ms.subservice
Add text & formatting to Word table cells programmatically
Learn how you can programmatically add text and formatting to cells in Microsoft Office Word tables.
02/02/2017
how-to
VB
CSharp
cells, adding text and formatting
text [Office development in Visual Studio], adding to Word tables
formatting [Office development in Visual Studio]
tables [Office development in Visual Studio], adding text and formatting
John-Hart
johnhart
mijacobs
office-development

Programmatically add text and formatting to cells in Word tables

Each table consists of a collection of cells. Each individual xref:Microsoft.Office.Interop.Word.Cell object represents one cell in the table. You refer to each cell by its location in the table. This example refers to the cell located in the first row and the first column of the table; adds text to the cell; and applies formatting.

[!INCLUDEappliesto_wdalldocapp]

To add text and formatting to cells

  1. Refer to the cell by its location in the table, add text to the cell, and apply the formatting.

    The following code example can be used in a document-level customization. To use this example, run it from the ThisDocument class in your project.

    :::code language="csharp" source="../vsto/codesnippet/CSharp/Trin_VstcoreWordAutomationCS/ThisDocument.cs" id="Snippet97":::

    :::code language="vb" source="../vsto/codesnippet/VisualBasic/Trin_VstcoreWordAutomationVB/ThisDocument.vb" id="Snippet97":::

    The following code example can be used in a VSTO Add-in. This example uses the active document. To use the example, run it from the ThisAddIn class in your project.

    :::code language="csharp" source="../vsto/codesnippet/CSharp/Trin_VstcoreWordAutomationAddIn/ThisAddIn.cs" id="Snippet97":::

    :::code language="vb" source="../vsto/codesnippet/VisualBasic/Trin_VstcoreWordAutomationAddIn/ThisAddIn.vb" id="Snippet97":::

Related content