vba code in word to delete line having inline shape
I am using this type of code .I have to delete entire line which contain image of height and width 24.If I skip "Selection.Rows.Delete" this line then it is deleting all shapes in 2 attempts but give run time error. I am new to VBA . So please suggest me how to correct this code
Sub our()
Dim iShapeCount As Integer
Dim iILShapeCount As Integer
Dim DocThis As Document
Dim J As Integer
Dim K As Integer
Dim sTemp1 As Integer
Dim sTemp2 As Integer
Set DocThis = ActiveDocument
iShapeCount = DocThis.Shapes.Count
For J = 1 To iShapeCount
sTemp1 = DocThis.Shapes(J).Height
sTemp2 = DocThis.Shapes(J).Width
If sTemp1 = 24 And sTemp2 = 24 Then
DocThis.Shapes(J).Delete
Selection.Rows.Delete
End If
Next J
iILShapeCount = DocThis.InlineShapes.Count
For J = 1 To iILShapeCount
sTemp1 = DocThis.InlineShapes(J).Height
sTemp2 = DocThis.InlineShapes(J).Width
If sTemp1 = 24 And sTemp2 = 24 Then
DocThis.InlineShapes(J).Delete
Selection.Rows.Delete
End If
Next J
End Sub
|