Hello All,
I have a macro which creates a Word document and applies some editing. I am now trying to search for a specific word in the document and deleting the line the text appears in.
I have found the following code which works in Word VBA, however using it in Excel does nothing.
How can I adapt this or is there an alternative method?
Thanks in advance.
I have a macro which creates a Word document and applies some editing. I am now trying to search for a specific word in the document and deleting the line the text appears in.
I have found the following code which works in Word VBA, however using it in Excel does nothing.
VBA Code:
Sub del_txt_row()
Dim oRng As Word.Range
Dim oRngDelete As Word.Range
Set oRng = ActiveDocument.Range
With oRng.find
.Text = "Not Applicable"
While .Execute
oRng.Select
Set oRngDelete = ActiveDocument.Bookmarks("\Line").Range
oRngDelete.delete
Wend
End With
End Sub
How can I adapt this or is there an alternative method?
Thanks in advance.