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
|