Yet another Multi-Select Listbox in Userform question
Hi,
I've been through most of the posts related to Multi-Select Listbox in a Userform.
I have a simple letter that triggers a Userform asking for a surname and a Multi-Select Listbox (called services).
In the word doc I assigned Doc Variable var1 for the name and Doc Variable var2 to include the options chosen in the Listbox.
The problem is I can't seem to make it work.
My Ok button code is:
Private Sub cmdOK_Click()
Set oVars = ActiveDocument.Variables
Hide
oVars("var1").Value = surname.Value
ActiveDocument.Fields.Update
Set oVars = Nothing
Dim i As Long
Dim StrOut As String
For i = 0 To Me.services.ListCount - 1
If Me.services.Selected(i) Then
StrOut = StrOut & Me.services.List(i) & vbCr
End If
Next i
oVars("var3") = StrOut
Unload Me
End Sub
If I change oVars("var3") to MsgBox, the code works. But it doesn't insert the options in the document, of course, as it's a MsgBox.
Any help?
Thanks!
Javier
|