Hi Andrew, just tried it out and has given me a error (attached as image) below is the code hopefully I have done it right?
Sub INSERT_GRID()
'
' INSERT_GRID Macro
'
'
Selection.ConvertToTable Separator:=wdSeparateByParagraphs, NumColumns:=5, _
NumRows:=25, AutoFitBehavior:=wdAutoFitFixed
With Selection.Tables(1)
.Style = "Table Grid"
.ApplyStyleHeadingRows = True
.ApplyStyleLastRow = False
.ApplyStyleFirstColumn = True
.ApplyStyleLastColumn = False
End With
Selection.Tables(1).Rows.SetLeftIndent leftIndent:=-8.5, RulerStyle:= _
wdAdjustNone
Selection.Tables(1).Rows.SetLeftIndent leftIndent:=-15.9, RulerStyle:= _
wdAdjustNone
Selection.Tables(1).Rows.SetLeftIndent leftIndent:=-22.95, RulerStyle:= _
wdAdjustNone
Selection.Tables(1).Rows.SetLeftIndent leftIndent:=-22.95, RulerStyle:= _
wdAdjustNone
Selection.Tables(1).Columns(1).SetWidth ColumnWidth:=28.35, RulerStyle:= _
wdAdjustNone
Selection.Tables(1).Columns(2).SetWidth ColumnWidth:=127.6, RulerStyle:= _
wdAdjustNone
Selection.Tables(1).Columns(3).SetWidth ColumnWidth:=226.8, RulerStyle:= _
wdAdjustNone
Selection.Tables(1).Columns(4).SetWidth ColumnWidth:=212.6, RulerStyle:= _
wdAdjustNone
Selection.Tables(1).Columns(5).SetWidth ColumnWidth:=212.65, RulerStyle:= _
wdAdjustNone
With Selection.Tables(1)
With .Borders(wdBorderLeft)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = -603923969
End With
With .Borders(wdBorderRight)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = -603923969
End With
With .Borders(wdBorderTop)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = -603923969
End With
With .Borders(wdBorderBottom)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = -603923969
End With
With .Borders(wdBorderHorizontal)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = -603923969
End With
With .Borders(wdBorderVertical)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = -603923969
End With
.Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone
.Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone
.Borders.Shadow = False
End With
With Options
.DefaultBorderLineStyle = wdLineStyleSingle
.DefaultBorderLineWidth = wdLineWidth050pt
.DefaultBorderColor = -603923969
End With
With Selection.Tables(1)
With .Borders(wdBorderLeft)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = -603923969
End With
With .Borders(wdBorderRight)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = -603923969
End With
With .Borders(wdBorderTop)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = -603923969
End With
With .Borders(wdBorderBottom)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = -603923969
End With
With .Borders(wdBorderHorizontal)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = -603923969
End With
With .Borders(wdBorderVertical)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = -603923969
End With
.Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone
.Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone
.Borders.Shadow = False
End With
With Selection.Sections(1)
With .Borders(wdBorderLeft)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth025pt
.Color = -603923969
End With
With .Borders(wdBorderRight)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth025pt
.Color = -603923969
End With
With .Borders(wdBorderTop)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth025pt
.Color = -603923969
End With
With .Borders(wdBorderBottom)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth025pt
.Color = -603923969
End With
With .Borders
.DistanceFrom = wdBorderDistanceFromPageEdge
.AlwaysInFront = True
.SurroundHeader = True
.SurroundFooter = True
.JoinBorders = False
.DistanceFromTop = 5
.DistanceFromLeft = 5
.DistanceFromBottom = 5
.DistanceFromRight = 5
.Shadow = False
.EnableFirstPageInSection = True
.EnableOtherPagesInSection = True
.ApplyPageBordersToAllSections
End With
End With
With Options
.DefaultBorderLineStyle = wdLineStyleSingle
.DefaultBorderLineWidth = wdLineWidth050pt
.DefaultBorderColor = -603923969
End With
With Selection.Tables(1)
.TopPadding = CentimetersToPoints(0.45)
.BottomPadding = CentimetersToPoints(0.45)
.LeftPadding = CentimetersToPoints(0.19)
.RightPadding = CentimetersToPoints(0.19)
.SPACING = 0
.AllowPageBreaks = True
.AllowAutoFit = True
End With
End Sub
|