Tables can drive me to the point of insanity.
If I have a four row x three column table in a document, I can select one of the column 2 cells and adjust its width without affecting the width of the overall row. If I try that with VBA the overall row size is changed.
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oTbl As Table
Set oTbl = ActiveDocument.Tables.Add(Selection.Range, 4, 3, wdWord8TableBehavior, wdAutoFitWindow)
oTbl.Range.Cells(5).Width = InchesToPoints(1)
lbl_Exit:
Exit Sub
End Sub
I can work around that with what I feel is a cumbersome process:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oTbl As Table
Dim dblW As Double
Set oTbl = ActiveDocument.Tables.Add(Selection.Range, 4, 3, wdWord8TableBehavior, wdAutoFitWindow)
'Option A
oTbl.Range.Cells(5).Width = InchesToPoints(1)
'at this point the overall row not longer is fit to window.
'Option B
dblW = oTbl.Range.Cells(5).Width + oTbl.Range.Cells(6).Width
oTbl.Range.Cells(5).Width = InchesToPoints(1)
oTbl.Range.Cells(6).Width = dblW - oTbl.Range.Cells(5).Width
lbl_Exit:
Exit Sub
End Sub
Is there some setting that can be applied to the table (I thought wdAutoFitWindow) so that regardless of what you do to individual cells (provided you don't try something illogical) that the overall table row remains the same width?