Thanks Guessed for your reply. Well, I have failed.
Here a simpler macro.
Code:
Option Explicit
Sub BMTest()
Dim tmp As String
tmp = "2021"
WB "BM1", tmp
tmp = "52"
WB "BM2", tmp
tmp = "10x"
WB "BM3", tmp
tmp = "2021"
WB "BM4", tmp
tmp = "52"
WB "BM5", tmp
tmp = "10x"
WB "BM6", tmp
End Sub
Public Sub WB(ByVal BName As String, ByVal inhalt As String)
If ActiveDocument.Bookmarks.Exists(BName) Then
Dim r As Range
Set r = ActiveDocument.Bookmarks(BName).Range
r.Text = inhalt
ActiveDocument.Bookmarks.Add BName, r
Else
Debug.Print "Bookmark not found: " & BName
End If
End Sub
In word, copy the following and insert the bookmarks
Code:
/* This works (note the space)*/
KTP.EG.[BM1] [BM2] [BM3]
/* This fails */
KTP.EG.[BM4][BM5][BM6]
This is my result.
Code:
KTP.EG.2021 52 10x
KTP.EG.10x