Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.tables
Snake Snake is offline
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.word.tables
Lene Fredborg Lene Fredborg is offline
external usenet poster
 
Posts: 1,291
Default 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   Report Post  
Posted to microsoft.public.word.tables
Lene Fredborg Lene Fredborg is offline
external usenet poster
 
Posts: 1,291
Default 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   Report Post  
Posted to microsoft.public.word.tables
Snake Snake is offline
external usenet poster
 
Posts: 2
Default 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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using borders in tables in 2003 Jackie D Tables 6 November 7th 07 08:28 AM
Need a macro to put borders around every occurrence of a word Wiley Microsoft Word Help 2 September 29th 06 09:07 PM
Tables - Borders and Shading Helen Tables 2 February 21st 06 04:28 PM
how do I add tables and borders to my toolbar stopfordj Tables 2 February 11th 06 06:09 PM
Borders, tables and bullets when designing templates! JillyW Microsoft Word Help 2 June 22nd 05 02:26 PM


All times are GMT +1. The time now is 04:20 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"