View Single Post
 
Old 05-03-2021, 02:41 AM
frreubi frreubi is offline Windows 10 Office 2013
Novice
 
Join Date: Apr 2021
Location: Laag-Soeren, The Netherlands
Posts: 4
frreubi is on a distinguished road
Default Problem solved

With a small change to the code it worked;

Sub DemoReplaceBookmark()
Dim aRng As Range, aField As Field
Set aRng = ActiveDocument.Bookmarks("aaa").Range
Set aField = ActiveDocument.Fields.Add(Range:=aRng, Text:="DOCPROPERTY ''"Title with spaces""")
aRng.InsertBefore "text in front"
aRng.End = aField.Result.End + 1
aRng.InsertAfter "text at end"
'aRng.Select
ActiveDocument.Bookmarks.Add Name:="aaa", Range:=aRng
End Sub
Reply With Quote