Microsoft Word VBA Tables Column and Row Manipulation 

Microsoft Word VBA Tables column and row manipulation is easiest when using a recorded macro as your starting point.

The following recorded macro inserts or adds a default table of 2 rows and 5 colums. then it inserts a row and then deletes the row.

Once again, the easiest way to work with a table is to record a macro as your basis, and then adjust the code from there...

Go to the Tools menu > Macros and choose Record New Macro.

Insert a table, add rows/columns, format the columns/rows and the text or what ever you need to accomplish.

 Documents.Add DocumentType:=wdNewBlankDocument
ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=2, _
NumColumns:= 5, DefaultTableBehavior:=wdWord9TableBehavior, _
AutoFitBehavior:= wdAutoFitFixed
With Selection.Tables(1)
If .Style <> "Table Grid" Then
.Style = "Table Grid"
End If
.ApplyStyleHeadingRows = True
.ApplyStyleLastRow = True
.ApplyStyleFirstColumn = True
.ApplyStyleLastColumn = True
End With
Selection.InsertRowsBelow 1
Selection.Rows.Delete
  
This site is powered by Site Build It!. If you enjoy it, please check out the
Site Build It homepage
 to learn more and on how to build a success-guaranteed site with no technical skills.

Custom Search






Return from Microsoft Word VBA Tables Column to VBA Code Samples

Return to our Home page