PDA

View Full Version : Newbie listbox blues please can anybody help



emsa
08-31-2006, 08:22 AM
I have SOMEHOW managed :dunno to use some code thanks to this forum :bow: that will allow me to select item(s) from a listbox on a vba form and for those items to transfer to another listbox located on a word form (.dot). This process is initiated by a command button also located on the word form :clap: . However, when I select New document based on my template, all seems great but the items, when selected do not go into the listbox on my word form (.doc):( . I would also like the items to display horizontally across the listbox and not in a column: pray2:. I have attached the template if anybody is interested in assisting me with this problem. Many thanks.

Here is the code I used and modified slightly to include my listbox items.

Option Explicit
Private Sub CommandButton1_Click()
Dim i As Integer
ThisDocument.ListBox1.Clear

For i = 0 To Me.ListBox1.ListCount - 1
If Me.ListBox1.Selected(i) = True Then
ThisDocument.ListBox1.AddItem Me.ListBox1.List(i)
End If
Next i
Unload Me
End Sub

Private Sub UserForm_Initialize()
Dim vArray As Variant
vArray = Array("cs", "da", "de", "et", "el", "en", "es", "fr", "it", "lv", "lt", "hu", "mt", "nl", "pl", "pt", "sk", "sl", "fi", "sv")
Me.ListBox1.List = vArray

End Sub