emsa
08-30-2006, 09:48 AM
Sorry me again. I was kindly given some code (see below) to experiment with and it was pretty good seeing the results come up in the message box (little things!). Unfortunately, I require the results to be entered onto the word form itself. The vba form also loads when I open the document template but I need it to open only when a user is completing the form and gets to a certain formfield if that's at all possible. If anybody can be of assistance, I would be eternally grateful.
Private Sub CommandButton1_Click()
Dim counter As Integer
'loop through the list
For counter = 0 To ListBox1.ListCount - 1
'check if the item is selected
If ListBox1.Selected(counter) Then
'add here your code with what to do with the selected item
'as example shows a msgbox with the selected value
MsgBox ListBox1.List(counter)
End If
Next
End Sub
Private Sub Document_Open()
'When the document is opened add the different options
ListBox1.AddItem ("cs")
ListBox1.AddItem ("da")
ListBox1.AddItem ("de")
ListBox1.AddItem ("et")
ListBox1.AddItem ("el")
ListBox1.AddItem ("en")
ListBox1.AddItem ("es")
ListBox1.AddItem ("fr")
ListBox1.AddItem ("it")
ListBox1.AddItem ("lv")
ListBox1.AddItem ("lt")
ListBox1.AddItem ("hu")
ListBox1.AddItem ("mt")
ListBox1.AddItem ("nl")
ListBox1.AddItem ("pl")
ListBox1.AddItem ("pt")
ListBox1.AddItem ("sk")
ListBox1.AddItem ("sl")
ListBox1.AddItem ("fi")
ListBox1.AddItem ("sv")
End Sub
Private Sub CommandButton1_Click()
Dim counter As Integer
'loop through the list
For counter = 0 To ListBox1.ListCount - 1
'check if the item is selected
If ListBox1.Selected(counter) Then
'add here your code with what to do with the selected item
'as example shows a msgbox with the selected value
MsgBox ListBox1.List(counter)
End If
Next
End Sub
Private Sub Document_Open()
'When the document is opened add the different options
ListBox1.AddItem ("cs")
ListBox1.AddItem ("da")
ListBox1.AddItem ("de")
ListBox1.AddItem ("et")
ListBox1.AddItem ("el")
ListBox1.AddItem ("en")
ListBox1.AddItem ("es")
ListBox1.AddItem ("fr")
ListBox1.AddItem ("it")
ListBox1.AddItem ("lv")
ListBox1.AddItem ("lt")
ListBox1.AddItem ("hu")
ListBox1.AddItem ("mt")
ListBox1.AddItem ("nl")
ListBox1.AddItem ("pl")
ListBox1.AddItem ("pt")
ListBox1.AddItem ("sk")
ListBox1.AddItem ("sl")
ListBox1.AddItem ("fi")
ListBox1.AddItem ("sv")
End Sub