tiredofit
Well-known Member
- Joined
- Apr 11, 2013
- Messages
- 1,924
- Office Version
- 365
- 2019
- Platform
- Windows
Assuming I have the following text:
I want to delete the text within two bookmarks in Word to end up with:
I found this code:
What happens when the code is run is BOOKMARK_START and BOOKMARK_END point to the same place, (which is BOOKMARK_START), ie:
Next time I insert something into BOOKMARK_START (and then try to delete it), it won't recognise BOOKARK_END (because it's the same location as BOOKMARK_START).
How can I get round this?
Thanks
Code:
Hello,
"BOOKMARK_START"
What are you doing
'BOOKMARK_END"
Call me
I want to delete the text within two bookmarks in Word to end up with:
Code:
Hello,
Call me
I found this code:
Code:
Dim pRange
Dim dRange
Dim myrange
pRange = ActiveDocument.Bookmarks("BOOKMARK_START").Range.Start
dRange = ActiveDocument.Bookmarks("BOOKMARK_END").Range.End
Set myrange = ActiveDocument.Range(Start:=pRange, End:=dRange)
myrange.Cut
What happens when the code is run is BOOKMARK_START and BOOKMARK_END point to the same place, (which is BOOKMARK_START), ie:
Code:
Hello,
BOOKMARK_START / BOOKMARK_END
Call me
Next time I insert something into BOOKMARK_START (and then try to delete it), it won't recognise BOOKARK_END (because it's the same location as BOOKMARK_START).
How can I get round this?
Thanks