View Single Post
 
Old 09-26-2021, 07:50 PM
Bikram Bikram is offline Windows 10 Office 2007
Advanced Beginner
 
Join Date: Jul 2021
Location: Nepal
Posts: 97
Bikram is on a distinguished road
Post Formatting only visible borders

Greetings to all the seniors, I am facing a problem and looking forward to a solution.

I have a macro to format tables in word

Sub formattingtables()
Dim doc as documents
Dim t as tables
Dim tt as integer
Dim I as integer

Set doc = Application.Activedocument
Set t = Activedocument.range.tables
tt = t.count

For i = 1 to tt

' If doc.tables(i) is in odd pages then
With doc.Tables(i)
With doc.Tables(i).Borders(wdBorderLeft)
.LineWidth = wdLineWidth150pt
.Color = -587137089
End With
With doc.Tables(i).Borders(wdBorderRight)
.LineWidth = wdLineWidth150pt
.Color = -587137089
End With

With doc.Tables(i).Borders(wdBorderTop)
.LineWidth = wdLineWidth150pt
.Color = -587137089
End With

With doc.Tables(i).Borders(wdBorderBottom)
.LineWidth = wdLineWidth150pt
.Color = -587137089
End With
With doc.Tables(i).Borders(wdBorderHorizontal)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = -587137089
End With
With doc.Tables(i).Borders(wdBorderVertical)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = -587137089
End With
With Options
.DefaultBorderLineStyle = wdLineStyleSingle
.DefaultBorderLineWidth = wdLineWidth150pt

End With
End With


Next


End Sub

It set the borders to all the borders whether it is visible or not. And that is the problem I am trying to solve. How can I format only those borders which are visible and leave the invisible borders untouched.

Looking forward for help. Thanks in advance!!
Reply With Quote