Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.tables
|
|||
|
|||
Change the Borders of all Tables (Macro)
Hello, I am about to go insane trying to figure this out. I want to change
the borders on all the Tables in one of my documents to the 'all' setting. I tried selecting all of them and changing it through the tabs but it only changes the first one highlighted. I'm not a programmer and I only know how to make Macros by recording them, but does anyone know how to make a Macro to permenently give all the tables in the document borders? Or if there is a command I don't see? Just the default style 1/2 point 'All' border. Thank you! |
#2
Posted to microsoft.public.word.tables
|
|||
|
|||
Change the Borders of all Tables (Macro)
The macro below should do what you want.
Sub ApplyBordersToAllTables() Dim oTable As Table Dim oBorderStyle As WdLineStyle Dim oBorderWidth As WdLineWidth Dim oBorderColor As WdColor Dim n As Long 'used to count tables for message Dim i As Long 'used with array Dim oArray As Variant 'Change the values below to apply other borders oBorderStyle = wdLineStyleSingle oBorderWidth = wdLineWidth050pt oBorderColor = wdColorBlack 'Define array with the borders to be changed 'Diagonal borders not included here oArray = Array(wdBorderTop, _ wdBorderLeft, _ wdBorderBottom, _ wdBorderRight, _ wdBorderHorizontal, _ wdBorderVertical) For Each oTable In ActiveDocument.Tables n = n + 1 With oTable For i = LBound(oArray) To UBound(oArray) With .Borders(oArray(i)) .LineStyle = oBorderStyle .LineWidth = wdLineWidth050pt .Color = wdColorBlack End With Next i End With Next oTable MsgBox "Finished applying borders to " & n & " tables." End Sub If you need help on installing macros, see: http://www.gmayor.com/installing_macro.htm -- Regards Lene Fredborg DocTools - Denmark www.thedoctools.com Document automation - add-ins, macros and templates for Microsoft Word "Snake" wrote: Hello, I am about to go insane trying to figure this out. I want to change the borders on all the Tables in one of my documents to the 'all' setting. I tried selecting all of them and changing it through the tabs but it only changes the first one highlighted. I'm not a programmer and I only know how to make Macros by recording them, but does anyone know how to make a Macro to permenently give all the tables in the document borders? Or if there is a command I don't see? Just the default style 1/2 point 'All' border. Thank you! |
#3
Posted to microsoft.public.word.tables
|
|||
|
|||
Change the Borders of all Tables (Macro)
Ooops. A correction to my first post - in the macro, in the "For i" loop,
replace the following two lines : ..LineWidth = wdLineWidth050pt ..Color = wdColorBlack with these lines: ..LineWidth = oBorderWidth ..Color = oBorderColor The macro works OK but the idea was that you should be able just to correct the values in top of the macro in order to apply another border style, width and color (I forgot to correct the values after a copy-paste€¦). -- Regards Lene Fredborg DocTools - Denmark www.thedoctools.com Document automation - add-ins, macros and templates for Microsoft Word "Lene Fredborg" wrote: The macro below should do what you want. Sub ApplyBordersToAllTables() Dim oTable As Table Dim oBorderStyle As WdLineStyle Dim oBorderWidth As WdLineWidth Dim oBorderColor As WdColor Dim n As Long 'used to count tables for message Dim i As Long 'used with array Dim oArray As Variant 'Change the values below to apply other borders oBorderStyle = wdLineStyleSingle oBorderWidth = wdLineWidth050pt oBorderColor = wdColorBlack 'Define array with the borders to be changed 'Diagonal borders not included here oArray = Array(wdBorderTop, _ wdBorderLeft, _ wdBorderBottom, _ wdBorderRight, _ wdBorderHorizontal, _ wdBorderVertical) For Each oTable In ActiveDocument.Tables n = n + 1 With oTable For i = LBound(oArray) To UBound(oArray) With .Borders(oArray(i)) .LineStyle = oBorderStyle .LineWidth = wdLineWidth050pt .Color = wdColorBlack End With Next i End With Next oTable MsgBox "Finished applying borders to " & n & " tables." End Sub If you need help on installing macros, see: http://www.gmayor.com/installing_macro.htm -- Regards Lene Fredborg DocTools - Denmark www.thedoctools.com Document automation - add-ins, macros and templates for Microsoft Word "Snake" wrote: Hello, I am about to go insane trying to figure this out. I want to change the borders on all the Tables in one of my documents to the 'all' setting. I tried selecting all of them and changing it through the tabs but it only changes the first one highlighted. I'm not a programmer and I only know how to make Macros by recording them, but does anyone know how to make a Macro to permenently give all the tables in the document borders? Or if there is a command I don't see? Just the default style 1/2 point 'All' border. Thank you! |
#4
Posted to microsoft.public.word.tables
|
|||
|
|||
Change the Borders of all Tables (Macro)
Thank you! That does help indeed, quite more then I hoped. Now I can get back
to work on this. Thanks again! "Lene Fredborg" wrote: Ooops. A correction to my first post - in the macro, in the "For i" loop, replace the following two lines : .LineWidth = wdLineWidth050pt .Color = wdColorBlack with these lines: .LineWidth = oBorderWidth .Color = oBorderColor The macro works OK but the idea was that you should be able just to correct the values in top of the macro in order to apply another border style, width and color (I forgot to correct the values after a copy-paste€¦). -- Regards Lene Fredborg DocTools - Denmark www.thedoctools.com Document automation - add-ins, macros and templates for Microsoft Word "Lene Fredborg" wrote: The macro below should do what you want. Sub ApplyBordersToAllTables() Dim oTable As Table Dim oBorderStyle As WdLineStyle Dim oBorderWidth As WdLineWidth Dim oBorderColor As WdColor Dim n As Long 'used to count tables for message Dim i As Long 'used with array Dim oArray As Variant 'Change the values below to apply other borders oBorderStyle = wdLineStyleSingle oBorderWidth = wdLineWidth050pt oBorderColor = wdColorBlack 'Define array with the borders to be changed 'Diagonal borders not included here oArray = Array(wdBorderTop, _ wdBorderLeft, _ wdBorderBottom, _ wdBorderRight, _ wdBorderHorizontal, _ wdBorderVertical) For Each oTable In ActiveDocument.Tables n = n + 1 With oTable For i = LBound(oArray) To UBound(oArray) With .Borders(oArray(i)) .LineStyle = oBorderStyle .LineWidth = wdLineWidth050pt .Color = wdColorBlack End With Next i End With Next oTable MsgBox "Finished applying borders to " & n & " tables." End Sub If you need help on installing macros, see: http://www.gmayor.com/installing_macro.htm -- Regards Lene Fredborg DocTools - Denmark www.thedoctools.com Document automation - add-ins, macros and templates for Microsoft Word "Snake" wrote: Hello, I am about to go insane trying to figure this out. I want to change the borders on all the Tables in one of my documents to the 'all' setting. I tried selecting all of them and changing it through the tabs but it only changes the first one highlighted. I'm not a programmer and I only know how to make Macros by recording them, but does anyone know how to make a Macro to permenently give all the tables in the document borders? Or if there is a command I don't see? Just the default style 1/2 point 'All' border. Thank you! |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Using borders in tables in 2003 | Tables | |||
Need a macro to put borders around every occurrence of a word | Microsoft Word Help | |||
Tables - Borders and Shading | Tables | |||
how do I add tables and borders to my toolbar | Tables | |||
Borders, tables and bullets when designing templates! | Microsoft Word Help |