Hello,
i am trying to populate a formfield with items from a listbox which is populated via an array.
This is what i have so far:
Private Sub UserForm_Initialize()
Dim arrData As Variant
arrData = Array("Entry1", "Entry2", "Entry3", "Entry4", _
"Entry5", "Entry6")
ListBox1.List = arrData
End Sub
Public Sub cmdOK_Click()
Dim intListBox As Integer
Dim intAusgabe As Integer
For intListBox = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(intListBox) Then
intAusgabe = intListBox + 1
ActiveDocument.FormFields("Hinweise").Result = ListBox1.List(intAusgabe) & Chr(11)
End If
Next intListBox
Hide
lbl_Exit:
Exit Sub
End Sub
'Empty FormField Button
Private Sub cmdEmpty_Click()
ActiveDocument.FormFields("Hinweise").Result = ""
Hide
lbl_Exit:
Exit Sub
End Sub
'Cancel Button
Private Sub cmdESC_Click()
Unload Me
End Sub
The Problem is that when i select multiple items in the Listbox, only the last selected item gets transfered to the formfield.
(Item 1,2,4,6 selected, only item 6 is transfered etc.)
Does anyone know why this is happening and how to correct this issue?
Although the Items need to be written in a new line for each item. vbNewLine Does not work, is there an alternative?
Best Regards
Manuel