View Single Post
 
Old 06-15-2018, 02:00 PM
d4okeefe d4okeefe is offline Windows 10 Office 2016
Advanced Beginner
 
Join Date: Apr 2013
Posts: 77
d4okeefe is on a distinguished road
Default

No need. I think I get it. Try this on your word document. Ignore the spreadsheet for the moment. See if you get what you want. Use Ctrl-Z to undo if necessary.

Code:
Sub expand_bookmark_to_include_insertion()
    Dim bk As Bookmark
    Dim new_range As Range
    
    Set bk = ActiveDocument.Bookmarks(1)
    Dim bk_name As String: bk_name = bk.Name
    
    Set new_range = ActiveDocument.Range(bk.Start, bk.End)
    new_range.InsertAfter (vbCrLf & "Inserted text")
    bk.Delete

    Dim bk_new As Bookmark
    Set bk_new = Bookmarks.Add(bk_name, new_range)
End Sub
Reply With Quote