Format All Tables

K

Kevin Barmish

Windows 2000 Pro
MS Word 200

I am using a Third-Party Database program that generates long MS Word files.
These files contain hundreds of tables with border set to "NONE".
What I would like to do is make the borders on all tables "ALL".
To do this for an individual table I would:
1) Select table
2) Table Properties
3) Borders and Shading
4) Change the setting from "None" to "All"
5) Click Ok, Click Ok, to apply changes
Doing this procedure to each individual table would be too long and tedious
and thus I am looking for a solution to somehow apply these changes to all
tables in the document.

1) Is there a way to do this using Built-In MS Word features,
2) Or, is anyone able to think of an algorithm I can use to make a macro
to complete my task

There is "no solution" according to the Third-Party software company to
correct the issue from the DB Software end, and thus my only hope is to do
it in Word.

Thank you for your help,

Kevin Barmish
 
H

Helmut Weber

Hi Kevin,
HTH,
Sub test486()
' wdBorderTop ' -1
' wdBorderLeft ' -2
' wdBorderBottom ' -3
' wdBorderRight ' -4
' wdBorderHorizontal ' -5
' wdBorderVertical ' -6
Dim oTbl As Table
Dim l As Long ' Which border line
For Each oTbl In ActiveDocument.Tables
For l = -6 To -1
With oTbl.Borders(l)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
' maybe more options
End With
Next
Next
End Sub
 
C

Charles Kenyon

This macro seems to work in Word 2003. Should work in earlier versions.

Sub TableBorderOn()
' Written by Charles Kyle Kenyon 10 June 2004
' Applies Borders to all tables in document
'
Dim oTable As Table
Dim varLineStyle As Variant
Dim varLineWidth As Variant
Dim varBorderColor As Variant
'
' Assign styles to lines and borders
'
varLineStyle = wdLineStyleSingle
varLineWidth = wdLineWidth050pt
varBorderColor = wdColorAutomatic
'
' Make these defaults
'
With Options
.DefaultBorderLineStyle = varLineStyle
.DefaultBorderLineWidth = varLineWidth
.DefaultBorderColor = varBorderColor
End With
'
' Reset borders on all tables in document
'
For Each oTable In ActiveDocument.Tables
With oTable
With .Borders(wdBorderLeft)
.LineStyle = varLineStyle
.LineWidth = varLineWidth
.Color = varBorderColor
End With
With .Borders(wdBorderRight)
.LineStyle = varLineStyle
.LineWidth = varLineWidth
.Color = varBorderColor
End With
With .Borders(wdBorderTop)
.LineStyle = varLineStyle
.LineWidth = varLineWidth
.Color = varBorderColor
End With
With .Borders(wdBorderBottom)
.LineStyle = varLineStyle
.LineWidth = varLineWidth
.Color = varBorderColor
End With
With .Borders(wdBorderHorizontal)
.LineStyle = varLineStyle
.LineWidth = varLineWidth
.Color = varBorderColor
End With
With .Borders(wdBorderVertical)
.LineStyle = varLineStyle
.LineWidth = varLineWidth
.Color = varBorderColor
End With
.Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone
.Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone
.Borders.Shadow = False
End With
Next oTable
End Sub

This assumes only horizontal and vertical borders (no diagonals). Hope this
helps.
 
K

Kevin Barmish

Greg, EXACTLY what I wanted, thank you very much...
Just so you know MS Tech Support was unable to assist...
I didn't know you could activate individual tables in the macro... awesome
and thanks

Kevin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top