N
Neil Humphries
I need to delete specific paragraph borders in a document and leave all
others including those in tables alone. The ones I want to delete occur in
paragraphs with only right borders. They are the minority of paragraphs in
the document.
I think the code below expresses the logic, unfortunately it doesn't do
anything. I expect that I am not creating a valid selection. Any help will be
appreciated.
I am using Word 2007 SP1 on Win XP Pro 64.
Sub DeleteParaBorder()
Dim oPrg As Paragraph
For Each oPrg In ActiveDocument.Paragraphs
'check if there is a right border
If Selection.ParagraphFormat.Borders(wdBorderRight).LineStyle =
wdLineStyleSingle Then
'check that there is no left border
If Selection.ParagraphFormat.Borders(wdBorderLeft).LineStyle =
wdLineStyleNone Then
'check that there are no shadows
If Selection.ParagraphFormat.Borders.Shadow = False Then
'set the right border to none
Selection.ParagraphFormat.Borders(wdBorderRight).LineStyle =
wdLineStyleNone
End If
End If
End If
Next
others including those in tables alone. The ones I want to delete occur in
paragraphs with only right borders. They are the minority of paragraphs in
the document.
I think the code below expresses the logic, unfortunately it doesn't do
anything. I expect that I am not creating a valid selection. Any help will be
appreciated.
I am using Word 2007 SP1 on Win XP Pro 64.
Sub DeleteParaBorder()
Dim oPrg As Paragraph
For Each oPrg In ActiveDocument.Paragraphs
'check if there is a right border
If Selection.ParagraphFormat.Borders(wdBorderRight).LineStyle =
wdLineStyleSingle Then
'check that there is no left border
If Selection.ParagraphFormat.Borders(wdBorderLeft).LineStyle =
wdLineStyleNone Then
'check that there are no shadows
If Selection.ParagraphFormat.Borders.Shadow = False Then
'set the right border to none
Selection.ParagraphFormat.Borders(wdBorderRight).LineStyle =
wdLineStyleNone
End If
End If
End If
Next