VBA Code


All cell values in a table end in Chr(13) & Chr(7)


Be careful when using the VBA code Selection.MoveEnd as you can extend a selection by two characters and end up selecting two whole rows in a table


When you are at the "endofrowmark" in a table you are still considered within the table (ie selection.information(wdwithintable) = True


Dim objTable As Word.Table 
objTable = ActiveDocument.Range.Tables.Add( , row, column)


If objRange.Information(wdInformation.wdWithinTable) = True Then 

End If


Range Object

Dim objCell As Word.Cell 
objCell = objTable.Cell(row,column)
objCell.Range.Text = "some text"


objTable.Row(1).Range.Bold = 1 ' True  
objTable.Row(1).Range.Bold = 0 ' False
objTable.Row(1).Range.Bold = - 1'undefined = wdConstants.wdUndefined


objTable.AutoFitBehaviour(wdAutoFitBehavior.wdAutoFitContent) 

rows(1).spacebetweencolumns = 0 
documents("Temp.doc").tables(3)
activedocument.tables(1).range.cells.range.insertbefore text:="cell" & 5
.rows.allowbreakacrosspages = false
.converttotable seperator:=wdseperatebytabs,
                        numcolumns:="",
                        numrows:="",
                        format:=wdtableformatnone,
                        applyborders:=true,
                        applyshading:=true,
                        applyfont:=true,
                        applycolor:=true,
                        applyheadingrows:=true,
                       applylastrow:=false,
                       applyfirstcolumn:=true,
                       aplylastcolumn:=false,
                      autofit:=false

Select Continuous Cells

Set objRange = ActiveDocument.Range(Start:=.Tables(1).Cell(2,2).Range.Start, _ 
                                                End:=.Tables(1).Cell(4,4).Range.End)

This will create a range for a continuous group of cells.
The start must occur before the end, both in terms of rows and columns



© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext