Word VBA, Modify Table Data
In this article I will explain how you can use VBA to modify a table‘s data in word. If there are multiple tables in a word document the first thing to do is to determine which table you are going to modify. Basically tables are indexed starting from one. So the first table will have the index “1”, the second table will have the index “2” and so on. You can get a reference to the table using the code below:
The code above gives reference to the first table in the document. Using the code below you will be able to change the text in row 1 column 1 of the table:
ThisDocument.Tables.Item(1).Cell(1, 1).Range = "New Data"
The code below adds the text “More Data” to column 4, row 2 of the 3rd table:
ThisDocument.Tables.Item(3).Cell(2, 4).Range = "More Data"
You can download the file and code related to this article from the link below:
- VBA, Word Table Insert/Remove Rows/Columns
- Word VBA Resize Table Columns and Rows
- Word VBA, Delete Empty Rows From Tables
If you need assistance with your code, or you are looking for a VBA programmer to hire feel free to contact me. Also please visit my website www.software-solutions-online.com