M
MichaelB
I’m having a bit of trouble trying to understand how to format a tables
placement within a document. The below script has been put together (with
lots of help from others) and I’m unable to figure out how to set the table
position within the document. I have a few tables that need to be aligned to
the left (which I have done with the wdAlignRowLeft but I need to indent this
table 1.08†and I can’t seem to find the proper way to do this.
Any help would be greatly appreciated.
Sub ResizeTables()
Dim oTbl As Table
Dim iTbl As Integer
Dim oCl As Cell
Dim oRng As Range
For iTbl = ActiveDocument.Tables.Count To 1 Step -1
Set oTbl = ActiveDocument.Tables(iTbl)
Set oCl = oTbl.Cell(1, 1)
Set oRng = oCl.Range
oRng.MoveEnd Unit:=wdCharacter, Count:=-1
If oTbl.Columns.Count = 4 And oRng.Text = "Version" Then
ActiveDocument.Tables(iTbl).Rows.Alignment =
wdAlignRowLeft
ActiveDocument.Tables(iTbl).AutoFitBehavior
Behavior:=wdAutoFitFixed
ActiveDocument.Tables(iTbl).Columns.PreferredWidthType =
wdPreferredWidthPoints
ActiveDocument.Tables(iTbl).Columns(1).PreferredWidth =
InchesToPoints(0.88)
ActiveDocument.Tables(iTbl).Columns(2).PreferredWidth =
InchesToPoints(1.5)
ActiveDocument.Tables(iTbl).Columns(3).PreferredWidth =
InchesToPoints(0.94)
ActiveDocument.Tables(iTbl).Columns(4).PreferredWidth =
InchesToPoints(3#)
End If
Next iTbl
End Sub
placement within a document. The below script has been put together (with
lots of help from others) and I’m unable to figure out how to set the table
position within the document. I have a few tables that need to be aligned to
the left (which I have done with the wdAlignRowLeft but I need to indent this
table 1.08†and I can’t seem to find the proper way to do this.
Any help would be greatly appreciated.
Sub ResizeTables()
Dim oTbl As Table
Dim iTbl As Integer
Dim oCl As Cell
Dim oRng As Range
For iTbl = ActiveDocument.Tables.Count To 1 Step -1
Set oTbl = ActiveDocument.Tables(iTbl)
Set oCl = oTbl.Cell(1, 1)
Set oRng = oCl.Range
oRng.MoveEnd Unit:=wdCharacter, Count:=-1
If oTbl.Columns.Count = 4 And oRng.Text = "Version" Then
ActiveDocument.Tables(iTbl).Rows.Alignment =
wdAlignRowLeft
ActiveDocument.Tables(iTbl).AutoFitBehavior
Behavior:=wdAutoFitFixed
ActiveDocument.Tables(iTbl).Columns.PreferredWidthType =
wdPreferredWidthPoints
ActiveDocument.Tables(iTbl).Columns(1).PreferredWidth =
InchesToPoints(0.88)
ActiveDocument.Tables(iTbl).Columns(2).PreferredWidth =
InchesToPoints(1.5)
ActiveDocument.Tables(iTbl).Columns(3).PreferredWidth =
InchesToPoints(0.94)
ActiveDocument.Tables(iTbl).Columns(4).PreferredWidth =
InchesToPoints(3#)
End If
Next iTbl
End Sub