Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-05-2022, 12:22 AM
Cendrinne's Avatar
Cendrinne Cendrinne is offline Help, Please, Table Borders LineWidth act as a Variant. Why Variant disregards my variant value? Windows 10 Help, Please, Table Borders LineWidth act as a Variant. Why Variant disregards my variant value? Office 2019
Competent Performer
Help, Please, Table Borders LineWidth act as a Variant. Why Variant disregards my variant value?
 
Join Date: Aug 2019
Location: Montreal Quebec Canada
Posts: 190
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
  #2  
Old 09-05-2022, 04:05 AM
Italophile Italophile is online now Help, Please, Table Borders LineWidth act as a Variant. Why Variant disregards my variant value? Windows 11 Help, Please, Table Borders LineWidth act as a Variant. Why Variant disregards my variant value? Office 2021
Expert
 
Join Date: Mar 2022
Posts: 315
Italophile is just really niceItalophile is just really niceItalophile is just really niceItalophile is just really nice
Default

You need to delete the line
Code:
 sVar1 = aTbl.Borders(wdBorderBottom).LineWidth
Reply With Quote
  #3  
Old 09-05-2022, 07:34 PM
Cendrinne's Avatar
Cendrinne Cendrinne is offline Help, Please, Table Borders LineWidth act as a Variant. Why Variant disregards my variant value? Windows 10 Help, Please, Table Borders LineWidth act as a Variant. Why Variant disregards my variant value? Office 2019
Competent Performer
Help, Please, Table Borders LineWidth act as a Variant. Why Variant disregards my variant value?
 
Join Date: Aug 2019
Location: Montreal Quebec Canada
Posts: 190
Cendrinne is on a distinguished road
Default I've put an exclamation to ignore that line of script, I got an error message...

Hello,
I've tried it, but the error message is pointing towards the line ==> .LineWidth = sVar1.

So is it a bug with Word, or my script?

But thanks for trying.

I'll continue trial and error, if I come up with an answer, I'll update the post.

Cendrinne
Reply With Quote
  #4  
Old 09-05-2022, 09:39 PM
Cendrinne's Avatar
Cendrinne Cendrinne is offline Help, Please, Table Borders LineWidth act as a Variant. Why Variant disregards my variant value? Windows 10 Help, Please, Table Borders LineWidth act as a Variant. Why Variant disregards my variant value? Office 2019
Competent Performer
Help, Please, Table Borders LineWidth act as a Variant. Why Variant disregards my variant value?
 
Join Date: Aug 2019
Location: Montreal Quebec Canada
Posts: 190
Cendrinne is on a distinguished road
Default I've done so many test, that my Variant, it could be anything...

Hello, pros,

I've tried anything I could think off. Now today, the width is 0.75" by default, regardless what I put.

I've even put xx, and no error message and got still 0.75".

I'm thinking, it cannot be done. Looking into wdLineWidth = Returns a WdLineWidth constant.
So I guess, a variable is not possible.

What do you all think?

Cendrinne
Reply With Quote
  #5  
Old 09-05-2022, 09:49 PM
Guessed's Avatar
Guessed Guessed is offline Help, Please, Table Borders LineWidth act as a Variant. Why Variant disregards my variant value? Windows 10 Help, Please, Table Borders LineWidth act as a Variant. Why Variant disregards my variant value? Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

wdLineWidth050pt has a value of 4
wdLineWidth150pt has a value of 12

So it appears you can't type in a value in points and expect Word to be able to assign that correctly to the LineWidth property. The only acceptable choices in that series of constants are:
2, 4, 6, 8, 12, 18, 24, 36, 48

You can review these constant values by using the VBA editor and going to View>Object Browser and searching for wdLineWidth which is the common prefix for all the possible relevant constants.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #6  
Old 09-05-2022, 10:18 PM
Cendrinne's Avatar
Cendrinne Cendrinne is offline Help, Please, Table Borders LineWidth act as a Variant. Why Variant disregards my variant value? Windows 10 Help, Please, Table Borders LineWidth act as a Variant. Why Variant disregards my variant value? Office 2019
Competent Performer
Help, Please, Table Borders LineWidth act as a Variant. Why Variant disregards my variant value?
 
Join Date: Aug 2019
Location: Montreal Quebec Canada
Posts: 190
Cendrinne is on a distinguished road
Default Oh OK, Thanks so much for the info.....

Quote:
Originally Posted by Guessed View Post
wdLineWidth050pt has a value of 4
wdLineWidth150pt has a value of 12

So it appears you can't type in a value in points and expect Word to be able to assign that correctly to the LineWidth property. The only acceptable choices in that series of constants are:
2, 4, 6, 8, 12, 18, 24, 36, 48

You can review these constant values by using the VBA editor and going to View>Object Browser and searching for wdLineWidth which is the common prefix for all the possible relevant constants.
So it is doable eventually, right?
But I did also added a Dim pt As Points and when I've entered a value as a Point system, I've put 1,50pt, but still got 0.75".

But thanks

Cendrinne
Reply With Quote
  #7  
Old 09-05-2022, 11:14 PM
Guessed's Avatar
Guessed Guessed is offline Help, Please, Table Borders LineWidth act as a Variant. Why Variant disregards my variant value? Windows 10 Help, Please, Table Borders LineWidth act as a Variant. Why Variant disregards my variant value? Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

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
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #8  
Old 09-05-2022, 11:45 PM
Cendrinne's Avatar
Cendrinne Cendrinne is offline Help, Please, Table Borders LineWidth act as a Variant. Why Variant disregards my variant value? Windows 10 Help, Please, Table Borders LineWidth act as a Variant. Why Variant disregards my variant value? Office 2019
Competent Performer
Help, Please, Table Borders LineWidth act as a Variant. Why Variant disregards my variant value?
 
Join Date: Aug 2019
Location: Montreal Quebec Canada
Posts: 190
Cendrinne is on a distinguished road
Default OMG, so sweet of you, thank you :)

Quote:
Originally Posted by Guessed View Post
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

Last edited by Cendrinne; 09-06-2022 at 12:09 AM. Reason: Edited the comma's for decimal and put dot. Sorry my pc is in French.
Reply With Quote
  #9  
Old 09-06-2022, 12:10 AM
Cendrinne's Avatar
Cendrinne Cendrinne is offline Help, Please, Table Borders LineWidth act as a Variant. Why Variant disregards my variant value? Windows 10 Help, Please, Table Borders LineWidth act as a Variant. Why Variant disregards my variant value? Office 2019
Competent Performer
Help, Please, Table Borders LineWidth act as a Variant. Why Variant disregards my variant value?
 
Join Date: Aug 2019
Location: Montreal Quebec Canada
Posts: 190
Cendrinne is on a distinguished road
Default See my below post, I've removed your suggestion, and worked

Quote:
Originally Posted by Italophile View Post
You need to delete the line
Code:
 sVar1 = aTbl.Borders(wdBorderBottom).LineWidth
It was more than that suggestion, but I did keep your suggestion in mind, and it contributed to my script.

Thanks for your input by the way

Cendrinne
Reply With Quote
  #10  
Old 09-06-2022, 12:23 AM
Cendrinne's Avatar
Cendrinne Cendrinne is offline Help, Please, Table Borders LineWidth act as a Variant. Why Variant disregards my variant value? Windows 10 Help, Please, Table Borders LineWidth act as a Variant. Why Variant disregards my variant value? Office 2019
Competent Performer
Help, Please, Table Borders LineWidth act as a Variant. Why Variant disregards my variant value?
 
Join Date: Aug 2019
Location: Montreal Quebec Canada
Posts: 190
Cendrinne is on a distinguished road
Default

Here is my script for all tables in a document. Had to rearrange the order of certain things. But this below works for me
For this bellow script, I've created for the Last Row:

Code:
 
   Dim xTbl As Table
   Dim sVar1 As WdLineWidth           'For the Last Row: Value to put as Top Border
   Dim sVar2 As WdLineWidth           'For the Last Row: Value to put as Bottom Border
   Dim LineWidth As Borders
    
    sVar1 = InputBox("Last Row - Enter the size value from the below choices before the symbole = for the Top Border." _
      & 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")

    sVar2 = InputBox("Last Row - Enter the size value from the below choices before the symbole = for the Bottom Border." _
      & 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")
    
    For Each xTbl In ActiveDocument.Tables
      xTbl.Rows.Last.Range.Select

     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
  
   Next xTbl
  
  On Error GoTo 0
Hopefully it works for others on their PC's.

Cendrinne

Last edited by Cendrinne; 09-06-2022 at 12:27 AM. Reason: again, fixed commas, as decimals for dot's, since my system is in French.
Reply With Quote
  #11  
Old 09-11-2022, 04:13 AM
gmaxey gmaxey is offline Help, Please, Table Borders LineWidth act as a Variant. Why Variant disregards my variant value? Windows 10 Help, Please, Table Borders LineWidth act as a Variant. Why Variant disregards my variant value? Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,421
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

You could employ a simple userform with two listboxes and a command button. Let prone to user errors:

Code:
Option Explicit
Private Sub UserForm_Initialize()
 With ListBox1
   .AddItem
   .List(.ListCount - 1, 0) = "0.25 pt"
   .List(.ListCount - 1, 1) = 2
   .AddItem
   .List(.ListCount - 1, 0) = "0.50 pt"
   .List(.ListCount - 1, 1) = 4
   .AddItem
   .List(.ListCount - 1, 0) = "0.75 pt"
   .List(.ListCount - 1, 1) = 6
   .AddItem
   .List(.ListCount - 1, 0) = "1 pt"
   .List(.ListCount - 1, 1) = 8
   .AddItem
   .List(.ListCount - 1, 0) = "1.5 pt"
   .List(.ListCount - 1, 1) = 12
   .AddItem
   .List(.ListCount - 1, 0) = "2.25 pt"
   .List(.ListCount - 1, 1) = 18
   .AddItem
   .List(.ListCount - 1, 0) = "3.00 pt"
   .List(.ListCount - 1, 1) = 24
   .AddItem
   .List(.ListCount - 1, 0) = "4.5 pt"
   .List(.ListCount - 1, 1) = 36
   .AddItem
   .List(.ListCount - 1, 0) = "6 pt"
   .List(.ListCount - 1, 1) = 48
   .ListIndex = 3
  End With
  With ListBox2
    .List = ListBox1.List
    .ListIndex = 5
  End With
lbl_Exit:
  Exit Sub
End Sub

Private Sub CommandButton1_Click()
Dim oTbl As Table
  For Each oTbl In ActiveDocument.Tables
    oTbl.Rows.Last.Range.Select
    With Selection.Range
      With .Borders(wdBorderTop)
        .LineStyle = wdLineStyleSingle
        .LineWidth = ListBox1.Column(1)
        .Color = wdColorAutomatic
      End With
      With .Borders(wdBorderBottom)
        .LineStyle = wdLineStyleSingle
        .LineWidth = ListBox2.Column(1)
        .Color = wdColorAutomatic
      End With
    End With
  Next oTbl
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #12  
Old 09-12-2022, 10:51 PM
Cendrinne's Avatar
Cendrinne Cendrinne is offline Help, Please, Table Borders LineWidth act as a Variant. Why Variant disregards my variant value? Windows 10 Help, Please, Table Borders LineWidth act as a Variant. Why Variant disregards my variant value? Office 2019
Competent Performer
Help, Please, Table Borders LineWidth act as a Variant. Why Variant disregards my variant value?
 
Join Date: Aug 2019
Location: Montreal Quebec Canada
Posts: 190
Cendrinne is on a distinguished road
Default Hello, my old friend, nice to hear from you :)

Quote:
Originally Posted by gmaxey View Post
You could employ a simple userform with two listboxes and a command button. Let prone to user errors:

Code:
Option Explicit
Private Sub UserForm_Initialize()
 With ListBox1
   .AddItem
   .List(.ListCount - 1, 0) = "0.25 pt"
   .List(.ListCount - 1, 1) = 2
   .AddItem
   .List(.ListCount - 1, 0) = "0.50 pt"
   .List(.ListCount - 1, 1) = 4
   .AddItem
   .List(.ListCount - 1, 0) = "0.75 pt"
   .List(.ListCount - 1, 1) = 6
   .AddItem
   .List(.ListCount - 1, 0) = "1 pt"
   .List(.ListCount - 1, 1) = 8
   .AddItem
   .List(.ListCount - 1, 0) = "1.5 pt"
   .List(.ListCount - 1, 1) = 12
   .AddItem
   .List(.ListCount - 1, 0) = "2.25 pt"
   .List(.ListCount - 1, 1) = 18
   .AddItem
   .List(.ListCount - 1, 0) = "3.00 pt"
   .List(.ListCount - 1, 1) = 24
   .AddItem
   .List(.ListCount - 1, 0) = "4.5 pt"
   .List(.ListCount - 1, 1) = 36
   .AddItem
   .List(.ListCount - 1, 0) = "6 pt"
   .List(.ListCount - 1, 1) = 48
   .ListIndex = 3
  End With
  With ListBox2
    .List = ListBox1.List
    .ListIndex = 5
  End With
lbl_Exit:
  Exit Sub
End Sub

Private Sub CommandButton1_Click()
Dim oTbl As Table
  For Each oTbl In ActiveDocument.Tables
    oTbl.Rows.Last.Range.Select
    With Selection.Range
      With .Borders(wdBorderTop)
        .LineStyle = wdLineStyleSingle
        .LineWidth = ListBox1.Column(1)
        .Color = wdColorAutomatic
      End With
      With .Borders(wdBorderBottom)
        .LineStyle = wdLineStyleSingle
        .LineWidth = ListBox2.Column(1)
        .Color = wdColorAutomatic
      End With
    End With
  Next oTbl
lbl_Exit:
  Exit Sub
End Sub
OK, I'll look at it tomorrow.
Just came to check something, but must go to bed for work.

Night night. Nice hearing from you
__________________
_______________________________
Cendrinne
Reply With Quote
  #13  
Old 09-13-2022, 11:36 PM
Cendrinne's Avatar
Cendrinne Cendrinne is offline Help, Please, Table Borders LineWidth act as a Variant. Why Variant disregards my variant value? Windows 10 Help, Please, Table Borders LineWidth act as a Variant. Why Variant disregards my variant value? Office 2019
Competent Performer
Help, Please, Table Borders LineWidth act as a Variant. Why Variant disregards my variant value?
 
Join Date: Aug 2019
Location: Montreal Quebec Canada
Posts: 190
Cendrinne is on a distinguished road
Default Hi Greg, I've tried it but I'm not familiar how to fix it.......

Quote:
Originally Posted by gmaxey View Post
You could employ a simple userform with two listboxes and a command button. Let prone to user errors:

Code:
Option Explicit
Private Sub UserForm_Initialize()
 With ListBox1
   .AddItem
   .List(.ListCount - 1, 0) = "0.25 pt"
   .List(.ListCount - 1, 1) = 2
   .AddItem
   .List(.ListCount - 1, 0) = "0.50 pt"
   .List(.ListCount - 1, 1) = 4
   .AddItem
   .List(.ListCount - 1, 0) = "0.75 pt"
   .List(.ListCount - 1, 1) = 6
   .AddItem
   .List(.ListCount - 1, 0) = "1 pt"
   .List(.ListCount - 1, 1) = 8
   .AddItem
   .List(.ListCount - 1, 0) = "1.5 pt"
   .List(.ListCount - 1, 1) = 12
   .AddItem
   .List(.ListCount - 1, 0) = "2.25 pt"
   .List(.ListCount - 1, 1) = 18
   .AddItem
   .List(.ListCount - 1, 0) = "3.00 pt"
   .List(.ListCount - 1, 1) = 24
   .AddItem
   .List(.ListCount - 1, 0) = "4.5 pt"
   .List(.ListCount - 1, 1) = 36
   .AddItem
   .List(.ListCount - 1, 0) = "6 pt"
   .List(.ListCount - 1, 1) = 48
   .ListIndex = 3
  End With
  With ListBox2
    .List = ListBox1.List
    .ListIndex = 5
  End With
lbl_Exit:
  Exit Sub
End Sub

Private Sub CommandButton1_Click()
Dim oTbl As Table
  For Each oTbl In ActiveDocument.Tables
    oTbl.Rows.Last.Range.Select
    With Selection.Range
      With .Borders(wdBorderTop)
        .LineStyle = wdLineStyleSingle
        .LineWidth = ListBox1.Column(1)
        .Color = wdColorAutomatic
      End With
      With .Borders(wdBorderBottom)
        .LineStyle = wdLineStyleSingle
        .LineWidth = ListBox2.Column(1)
        .Color = wdColorAutomatic
      End With
    End With
  Next oTbl
lbl_Exit:
  Exit Sub
End Sub
You are WAY more advance than my level of knowledge. Wow, Wish you would make a book for less familiar people. Even stuff on your website, I'm not certain to understand lot's of contents.

Re this script,
I get an error message, and it highlights ListBox. It say's it's undefined Variable.
So I've tried to put Dim ListBox1 As ListBox, ListBox2 As ListBox = Worked but now it flags .AddItem

So I wish to have tried it, but I need more guidance to figure out what it's supposed to do.

But I'm truly grateful for your wanting to help me

Got to go to bed for now.

Night night
__________________
_______________________________
Cendrinne
Reply With Quote
  #14  
Old 09-14-2022, 01:28 AM
gmaxey gmaxey is offline Help, Please, Table Borders LineWidth act as a Variant. Why Variant disregards my variant value? Windows 10 Help, Please, Table Borders LineWidth act as a Variant. Why Variant disregards my variant value? Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,421
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

You have to create a userform with two listboxes and a command button. The code goes in the userform module. See Create & Employ a Userform
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #15  
Old 09-14-2022, 07:15 PM
Cendrinne's Avatar
Cendrinne Cendrinne is offline Help, Please, Table Borders LineWidth act as a Variant. Why Variant disregards my variant value? Windows 10 Help, Please, Table Borders LineWidth act as a Variant. Why Variant disregards my variant value? Office 2019
Competent Performer
Help, Please, Table Borders LineWidth act as a Variant. Why Variant disregards my variant value?
 
Join Date: Aug 2019
Location: Montreal Quebec Canada
Posts: 190
Cendrinne is on a distinguished road
Wink Ok nice, I'll try that this weekend. Weeks are pretty busy.

Quote:
Originally Posted by gmaxey View Post
You have to create a userform with two listboxes and a command button. The code goes in the userform module. See Create & Employ a Userform
I can't wait to try that this week-end. I like to learn new ways.
I'll let you know for sure.

Thanks Greg.
__________________
_______________________________
Cendrinne
Reply With Quote
Reply

Tags
borders, help please, variant

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with table borders synint Word 2 12-02-2021 01:44 AM
Help, Please, Table Borders LineWidth act as a Variant. Why Variant disregards my variant value? How is a variant array created to pass properties to a style? Peterson Word VBA 2 09-06-2021 05:52 PM
Help, Please, Table Borders LineWidth act as a Variant. Why Variant disregards my variant value? table over 2 pages without borders ljosmynd Word Tables 1 02-02-2016 12:29 AM
Help, Please, Table Borders LineWidth act as a Variant. Why Variant disregards my variant value? Page-crossing borders in a table with hidden between-cell borders tenpaiman Word 2 08-08-2012 07:20 PM
how can i make random variant neezeen Word 0 11-22-2011 08:08 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:08 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft