Table Borders

M

mmikedm1000

Hi, I am tring to have a macro remove table borders from all the tables in
an active document. This is the code I came up with, but it has some errors
I cannot fix.

Sub tableNoBorder()
Dim oTable As table
For Each oTable In ActiveDocument.Tables
oTable.Style = "Table Style1"
Next oTable

'
' Removes Table Borders
'

Dim oTbl As table
For Each oTbl In ActiveDocument.Tables
With oTbl.Borders
.Borders(wdBorderLeft).LineStyle = wdLineStyleNone
.Borders(wdBorderRight).LineStyle = wdLineStyleNone
.Borders(wdBorderTop).LineStyle = wdLineStyleNone
.Borders(wdBorderBottom).LineStyle = wdLineStyleNone
.Borders(wdBorderHorizontal).LineStyle = wdLineStyleNone
.Borders(wdBorderVertical).LineStyle = wdLineStyleNone
.Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone
.Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone
.Borders.Shadow = False
End With
On Error Resume Next
With Options
.DefaultBorderLineStyle = wdLineStyleSingle
.DefaultBorderLineWidth = wdLineWidth050pt
.DefaultBorderColor = wdColorAutomatic
End With
Next oTbl
End Sub

Any suggestions? Oh, the reason I am doing this is becuase I am importing
these documents to RoboHTML and it does not recognize the tables correctly.
 
N

nate

Is that the right way to use the with statement for that object.

seems like using the Borders twice isn't the correct way.
for example would you do this:

oTbl.Borders.Borders(wdBorderLeft).LineStyle =
or would it be
oTbl.Borders(wdBorderLeft).LineStyle =

if it is the second then maybe your with block needs to be

With oTbl
.Borders(------
end with
 
R

rhamre

Give this a whirl

Sub tableborder()

Dim tbl As Table

Application.ScreenUpdating = False

For Each tbl In ActiveDocument.Tables

tbl.Select

With Selection.Tables(1)

.Borders(wdBorderLeft).LineStyle = wdLineStyleNone
.Borders(wdBorderRight).LineStyle = wdLineStyleNone
.Borders(wdBorderTop).LineStyle = wdLineStyleNone
.Borders(wdBorderBottom).LineStyle = wdLineStyleNone
.Borders(wdBorderHorizontal).LineStyle = wdLineStyleNone
.Borders(wdBorderVertical).LineStyle = wdLineStyleNone
.Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone
.Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone
.Borders.Shadow = False

End With

Next tbl

Application.ScreenUpdating = True

End Sub
 

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