-1

I currently have a code that will delete a bookmark from a word document using the portion of my code displayed below:

For i = LBound(BookMarksToDelete) To UBound(BookMarksToDelete)
    wdDoc.Bookmarks(BookMarksToDelete(i)).Delete
Next i

Based on the snippet above, I was curious to if there was a way for me to recreate this portion in order to delete the text at the bookmark, along with the paragraph underneath it (Word document is in the form Header followed by Paragraph starting on next line)

Gary's Student
  • 95,722
  • 10
  • 59
  • 99
Jack Henderson
  • 93
  • 1
  • 12

2 Answers2

0
 Dim whattokill As Range

For i = LBound(BookMarksToDelete) To UBound(BookMarksToDelete)
    With wdDoc.Bookmarks(BookMarksToDelete(i))
        Set whattokill = .Range
        whattokill.Expand wdParagraph
        'repeat above line if you want more than one para
        whattokill.Delete
     End With
 Next i
Harassed Dad
  • 4,669
  • 1
  • 10
  • 12
0

I found a solution to my issue, the following code snippet will produce the desired result:

For i = LBound(BookMarksToDelete) To UBound(BookMarksToDelete)
    Set pRng = wdDoc.Bookmarks(BookMarksToDelete(i)).Range
    pRng.MoveEnd wdParagraph, 2
    pRng.Delete
Next i
Jack Henderson
  • 93
  • 1
  • 12