Quote:
Originally Posted by Guessed
Try this variation. It shows the ONLY possible values that can be entered and defaults to the same value as the first table in the document. I've coded it to apply all the same bottom row border settings as the first table in the document and allows you to override the bottom border setting that the first table had (if you wish to choose something else).
I did this because your code referenced the first table in the document and the first table in the selection. Those tables may or may not be the same thing.
Code:
Sub Table_Borders_LastRow()
Dim aTbl As Table, aTblSel As Table
Dim iLineWidth As Integer 'Border size for the bottom row, bottom border.
Set aTbl = ActiveDocument.Tables(1)
Set aTblSel = Selection.Tables(1)
iLineWidth = aTbl.Borders(wdBorderBottom).LineWidth 'size of bottom border on first table
iLineWidth = InputBox("Enter the Border size for the bottom row/bottom border." & vbCr & _
"Choices are: 2, 4, 6, 8, 12, 18, 24, 36, 48", "SUGGESTION", iLineWidth) 'suggestion = first table's border size
With aTblSel.Rows.Last
.Borders = aTbl.Rows.Last.Borders
.Borders(wdBorderBottom).LineWidth = iLineWidth
End With
End Sub
|
Result:
I've tried it, however, it gave me an error message, Re the line:
.Borders(wdBorderBottom).LineWidth = iLineWidth.
I don't know how to fix it, however, I'm glad to have fixed my above script. I've even added on the same row a Top and Bottom Value as InputBoxes.
I've replaced ''As Variant'' for ''WdLineWidth'', Works great.
My script is maybe not as a pro like yourself would do it, but for No formal training, just analyzing scripts, I can say I'm getting not bad, right? Please give me a bone ''encouragement''

.
Here is my script:
Code:
Dim aTbl As Table
Dim sVar1 As WdLineWidth 'First Row - Top border
Dim sVar2 As WdLineWidth 'First Row - Bottom border
Dim LineWidth As Borders
Set aTbl = ActiveDocument.Tables(1)
sVar1 = InputBox("For First Row, Enter the value on Top from the below numbers before the = symbole." _
& vbCr & "Exemple : 2 =0.25/ 4 =0.50/ 6 =0.75/ 8 =1.00/" _
& vbCr & "12 =1.50/ 18 =2.25/ 24 =3.00/ 36 =4.50/ 48 =6.00.", "SUGGESTION", "18")
sVar2 = InputBox("For First Row, Enter the value on Bottom from the below numbers before the = symbole." _
& vbCr & "Exemple : 2 =0.25/ 4 =0.50/ 6 =0.75/ 8 =1.00/" _
& vbCr & "12 =1.50/ 18 =2.25/ 24 =3.00/ 36 =4.50/ 48 =6.00.", "SUGGESTION", "8")
With Selection.Tables(1)
.Rows.First.Range.Select
End With
With Selection.Range
With .Borders(wdBorderTop)
.LineStyle = wdLineStyleSingle
.LineWidth = sVar1
.Color = wdColorAutomatic
End With
With .Borders(wdBorderBottom)
.LineStyle = wdLineStyleSingle
.LineWidth = sVar2
.Color = wdColorAutomatic
End With
End With
On Error GoTo 0
And as the other person mentioned, sorry don't remember the person's name, I didn't need to put
Code:
'sVar1 = aTbl.Borders(wdBorderTop).LineWidth
Note: I was reworking on the First Row, but I could easily modify it for the Bottom Row, like your script and my original post.
Once I know how to do this, I could now try to do it to all tables in a document. At times, I have over 80 tables in a document, which takes me much times, to fix them to be constant.
From the bottom of my heart, thank you for guiding me and helping me or anyone with those type of script's
Cendrinne