Sarahmueller
New Member
- Joined
- May 17, 2020
- Messages
- 24
- Office Version
- 365
- 2016
- Platform
- Windows
Hello,
I hope you all are well.
I want to write a macro to delete two lines above a bookmark in a word document. So far so good, but the bookmark itself should not be deleted.
I have come up with the following code:
But this macro also deletes the bookmark.
Do you have an idea how to solve this problem?
Best regards and a have nice day,
Sarah
I hope you all are well.
I want to write a macro to delete two lines above a bookmark in a word document. So far so good, but the bookmark itself should not be deleted.
I have come up with the following code:
VBA Code:
Sub DeletetwoLinesAboveBookmark1()
Dim r As Word.Range
Set r = ActiveDocument.Bookmarks("Bookmark1").Range
r.MoveStart wdSentence, -2
r.Delete
End Sub
But this macro also deletes the bookmark.
Do you have an idea how to solve this problem?
Best regards and a have nice day,
Sarah