View Single Post
 
Old 09-05-2022, 12:22 AM
Cendrinne's Avatar
Cendrinne Cendrinne is offline Windows 10 Office 2019
Competent Performer
 
Join Date: Aug 2019
Location: Montreal Quebec Canada
Posts: 200
Cendrinne is on a distinguished road
Default Help, Please, Table Borders LineWidth act as a Variant. Why Variant disregards my variant value?

Hello pros,
I've succeeded to create a macro for Table Borders LineWidth to act as a Variant for the Last Row, for the bottom border.

Re: LineWidth = (sVar1), it remains at 1,50pt. Why?

Code:
   
Sub Table_1_Borders_LastRow_Top_050pt_Bottom_Var()
   Dim aTbl As Table
   Dim sVar1 As Variant               'Border size for the bottom row, bottom border.
   Dim LineWidth As Borders

Set aTbl = ActiveDocument.Tables(1)

   With Selection.Tables(1)
       .Rows.Last.Range.Select
   End With

    sVar1 = InputBox("Enter the Border size for the bottom row, on bottom border." _
      & vbCr & "Exemple en pt : 0.25, 0.50, 0.75, 1.00, 1.50, 2.25, 3.00, 4.50, 6.00.", "SUGGESTION", "3")

sVar1 = aTbl.Borders(wdBorderBottom).LineWidth

     With Selection.Range
        With .Borders(wdBorderTop)
            .LineStyle = wdLineStyleSingle
            .LineWidth = wdLineWidth050pt
            .Color = wdColorAutomatic
        End With

        With .Borders(wdBorderBottom)
            .LineStyle = wdLineStyleSingle
           '.LineWidth = wdLineWidth150pt
            .LineWidth = sVar1
            .Color = wdColorAutomatic
        End With
     End With
  
  On Error GoTo 0

End Sub
I've just edited my question, cause Trial and Error, I got it to work without error message. BUT, now the variant value, is Disregarded, and it puts 1.50 pt regardless the value I put as a variant.

What am I doing wrong, in your opinion?

Could any expert guide me please? I would be sooooo grateful.

Cendrinne

Last edited by Cendrinne; 09-05-2022 at 02:27 AM. Reason: Got it to work, but still have an issue.....
Reply With Quote