Open your template and the attachment. From the VBA editor drag the userform from the example to your template. Copy the code from the ThisDocument module to the ThisDocument module of your template. Add a rich text content control to your template and title it "Link 1". (You can title it whatever you like, but make the change in the code to match.)
The ThisDocument module contains the code you need to change to supply your list
Code:
Option Explicit
Private Sub Document_ContentControlOnEnter(ByVal ContentControl As ContentControl)
Dim oFrm As UserForm1 'The name of the userform
Dim i As Integer
Dim orng As Range
Dim sText As String
If ContentControl.Title = "List 1" Then 'the name of the listbox
Set oFrm = New UserForm1
With oFrm
With .ListBox1 'the name of the listbox
'the items you want to add
.AddItem "pizza"
.AddItem "hamburgers"
.AddItem "hot dogs"
.AddItem "garden salad"
.AddItem "potato salad"
.AddItem "potato chips"
.MultiSelect = fmMultiSelectMulti
End With
.Show
With .ListBox1 'the name of the listbox
For i = 0 To .ListCount - 1
If .Selected(i) = True Then
sText = sText & .List(i) & vbCr
End If
Next i
If Not sText = "" Then sText = Left(sText, Len(sText) - 1)
End With
Set orng = ContentControl.Range
orng.Text = sText
orng.End = orng.End + 1
orng.Collapse 0
orng.Select
End With
End If
Unload oFrm
Set oFrm = Nothing
End Sub
The userform code is
Code:
Option Explicit
Private Sub CommandButton1_Click()
Hide
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then Cancel = True
lbl_Exit:
Exit Sub
End Sub