Deleting lines

L

LEU

I have a document with a lot of shapes in it. I have the following macro the
deletes only the lines. The problem is that it deletes all the lines. I need
help to fine-tune it to only delete the vertical lines.

Dim i As Long
For i = ActiveDocument.Range.ShapeRange.Count To 1 Step -1
If ActiveDocument.Range.ShapeRange(i).Type = msoLine Then
ActiveDocument.Range.ShapeRange(i).Delete
End If
Next
 
J

Jean-Guy Marcil

LEU was telling us:
LEU nous racontait que :
I have a document with a lot of shapes in it. I have the following
macro the deletes only the lines. The problem is that it deletes all
the lines. I need help to fine-tune it to only delete the vertical
lines.

Dim i As Long
For i = ActiveDocument.Range.ShapeRange.Count To 1 Step -1
If ActiveDocument.Range.ShapeRange(i).Type = msoLine Then
ActiveDocument.Range.ShapeRange(i).Delete
End If
Next

Try this:

'_______________________________________
Sub DeleteVerticalLines()

Dim i As Long

With ActiveDocument.Range.ShapeRange
For i = .Count To 1 Step -1
If .Item(i).Type = msoLine Then
If .Item(i).Width = 0 Then
.Item(i).Delete
End If
End If
Next
End With

End Sub
'_______________________________________

It would be easy to modify it to delete horizontal lines...

--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

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