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 |
|
|
John-Hart |
johnhart |
mijacobs |
office-development |
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]
-
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":::