Log in

View Full Version : Solved: Table borders different for first row



Dave T
08-09-2010, 06:33 PM
Hello All,

I have been using the following code to format the borders of a table.
However the code formats all the internal horizontal table borders the same (.LineStyle = wdLineStyleSingle and .LineWidth = wdLineWidth025pt).
I have been trying, without success, to format the bottom line of the heading row with a differnent line style (.LineStyle = wdLineStyleDouble and .LineWidth = wdLineWidth075pt)



With Selection.Tables(1)
.Rows.AllowBreakAcrossPages = False
.AllowAutoFit = False
.Rows(1).Shading.BackgroundPatternColor = wdColorAutomatic
With .Borders(wdBorderLeft)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth150pt
End With
With .Borders(wdBorderRight)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth150pt
End With
With .Borders(wdBorderTop)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth150pt
End With
With .Borders(wdBorderBottom)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth150pt
End With
With .Borders(wdBorderHorizontal)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth025pt
End With
With .Borders(wdBorderVertical)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth100pt
End With
End With


Most of my attempt have been along the lines of using
.Rows(1).Borders(wdBorderBottom)
Each attempt generally ends with the following error:
Compile error: Invalid or unqualified reference


Any help would be appreciated.

Regards,
Dave T

gmaxey
08-09-2010, 08:55 PM
Try:
Sub ScratchMaco()
With Selection.Tables(1)
.Rows.AllowBreakAcrossPages = False
.AllowAutoFit = False
.Rows(1).Shading.BackgroundPatternColor = wdColorAutomatic
With .Borders(wdBorderLeft)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth150pt
End With
With .Borders(wdBorderRight)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth150pt
End With
With .Borders(wdBorderTop)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth150pt
End With
With .Borders(wdBorderBottom)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth150pt
End With
With .Borders(wdBorderHorizontal)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth025pt
End With
With .Borders(wdBorderVertical)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth100pt
End With
With .Rows(1).Borders(wdBorderBottom)
.LineStyle = wdLineStyleDouble
.LineWidth = wdLineWidth075pt
End With
End With

Dave T
08-10-2010, 03:57 PM
Hello Greg,

Thank you very much for the solution.
Frustrating to see how close I was with all my attempts, especially when I see your reply was such a simple solution.

Regards,
Dave T

gmaxey
08-10-2010, 04:28 PM
You're welcome.