Option Explicit
Private Sub CommandButton1_Click()
Dim bmk As Bookmark
For Each bmk In ActiveDocument.Bookmarks
Select Case Split(bmk.Name, "_")(0)
Case "CompanyName"
InsertTextInBookmark bmk, txtCompanyName.Text
Case "Contact"
InsertTextInBookmark bmk, txtContact.Text
Case "Address"
'...
'Case ...
End Select
Next bmk
End Sub
Sub InsertTextInBookmark(bmk As Bookmark, strText As String)
Dim rng As Range
Set rng = bmk.Range
rng.Text = strText
're-add bookmark in case it was overwritten and
'to ensure that it contains the text
rng.Document.Bookmarks.Add bmk.Name, rng
End Sub
Option Explicit
Private Sub OK_Click()
Dim bmk As Bookmark
For Each bmk In ActiveDocument.Bookmarks
Select Case Split(bmk.Name, "_")(0)
Case "Radgiver10"
'Case "Radgiver10" is the name of the field in the Userform.
InsertTextInBookmark bmk, txtRådgiver.Text
'"txtRådgiver.Text" is the bookmark name.
Case "Radgiver10"
InsertTextInBookmark bmk, txtRådgiver01.Text
Case "Radgiver10"
InsertTextInBookmark bmk, txtRådgiver02.Text
Case "Oppdragsgiver10"
InsertTextInBookmark bmk, txtOppdragsgiver.Text
Case "Oppdragsgiver10"
InsertTextInBookmark bmk, txtOppdragsgiver02.Text
Case "Oppdragsgiver10"
InsertTextInBookmark bmk, txtOppdragsgiver03.Text
Case "Oppdragsgiver10"
InsertTextInBookmark bmk, txtOppdragsgiver04.Text
Case "Oppdragsgiver10"
InsertTextInBookmark bmk, txtOppdragsgiver05.Text
Case "Oppdragsgiver10"
InsertTextInBookmark bmk, txtOppdragsgiver06.Text
Case "LederFast"
InsertTextInBookmark bmk, txtStyrelederFast.Text
Case "LederTime"
InsertTextInBookmark bmk, txtStyrelederTime.Text
Case "MedlemFast"
InsertTextInBookmark bmk, txtStyremedlemFast.Text
Case "MedlemTime"
InsertTextInBookmark bmk, txtStyremedlemTime.Text
Case "RadgiverTime"
InsertTextInBookmark bmk, txtRadgiverTime.Text
End Select
Next bmk
End Sub
Sub InsertTextInBookmark(bmk As Bookmark, strText As String)
Dim rng As Range
Set rng = bmk.Range
rng.Text = strText
're-add bookmark in case it was overwritten and
'to ensure that it contains the text
rng.Document.Bookmarks.Add bmk.Name, rng
End Sub
Private Sub OK_Click()
Dim bmk As Bookmark
For Each bmk In ActiveDocument.Bookmarks
Select Case Split(bmk.Name, "_")(0)
Case "Radgiver"
'"Radgiver" is the first part of the bookmark name on the document.
InsertTextInBookmark bmk, txtRådgiver.Text
'"txtRådgiver.Text" is the text from the text box on the user form
Case "Oppdragsgiver"
InsertTextInBookmark bmk, txtOppdragsgiver.Text
Case "LederFast" 'if there is no "_" in the bookmark name, Split(bmk.Name, "_")(0) will return the whole name
InsertTextInBookmark bmk, txtStyrelederFast.Text
Case "LederTime"
InsertTextInBookmark bmk, txtStyrelederTime.Text
Case "MedlemFast"
InsertTextInBookmark bmk, txtStyremedlemFast.Text
Case "MedlemTime"
InsertTextInBookmark bmk, txtStyremedlemTime.Text
Case "RadgiverTime"
InsertTextInBookmark bmk, txtRadgiverTime.Text
End Select
Next bmk
End Sub
rng.Document.Bookmarks.Add bmk.Name, rng
Private Sub OK_Click()
Dim bmk As Bookmark
For Each bmk In ActiveDocument.Bookmarks
Select Case Split(bmk.Name, "_")(0)
Case "Rådgiver"
'"Radgiver" is the first part of the bookmark name on the document.
InsertTextInBookmark bmk, txtRadgiver.Text
'"txtRadgiver.Text" is the text from the text box on the user form
Case "Oppdragsgiver"
InsertTextInBookmark bmk, txtOppdragsgiver.Text
'if there is no "_" in the bookmark name, Split(bmk.Name, "_")(0) will return the whole name
Case "Kontaktperson"
InsertTextInBookmark bmk, txtKontaktperson
Case "StyrelederFast"
InsertTextInBookmark bmk, txtLederFast.Text
Case "StyrelederTime"
InsertTextInBookmark bmk, txtLederTime.Text
Case "StyremedlemFast"
InsertTextInBookmark bmk, txtMedlemFast.Text
Case "StyremedlemTime"
InsertTextInBookmark bmk, txtMedlemTime.Text
Case "RådgiverTime"
InsertTextInBookmark bmk, txtRadgiverTime.Text
End Select
Next bmk
End Sub
Sub InsertTextInBookmark(bmk As Bookmark, strText As String)
Dim rng As Range
Set rng = bmk.Range
rng.Text = strText
're-add bookmark in case it was overwritten and
'to ensure that it contains the text
rng.Document.Bookmarks.Add bmk.Name, rng
End Sub
For Each bmk In ActiveDocument.Bookmarks
For instance you could bookmark any text to be repeated and place Ref fields at the places that it is to be redisplayed.
You could use Form Fields or Content Controls, perhaps with the 'sub' form as a building block. It would be part of the document and not a sidebar.
The nearest that you could get to that would be as a VBA UserForm which could load text on to the document at locations defined by, say, pre-existing bookmarks.