Good Day
I hope someone can perhaps assist.
I am currently using the below listed code to populate 20 Text Form Field via a listbox wich is activated via a macro upon clicking on the text form field in word (The Form Fields are all in a table)
Currently In my Listbox I select either on to twenty wich will populate the necessary text form field in word , If I select more than twenty i will get a Msg Box wich will indicate that I selected to many and need to deselect. However if i deselect the records and click ok to update my text form field. I get the following error message.
Runtime Error 5941
The Requested member of the collection does not exist.
and if I select Debug it takes me to the following string
ActiveDocument.FormFields("Skill" & k).Result = _
SkillsArray(var2)
I was hoping someone could perhaps assist in what i could do to allow my text form fields to update after i receive the message. (This will only be if more than twenty records have been selected)
Private Sub cmdOK_Click()
Dim StrSkillList As String
Dim j As Long, k As Long
Dim var, var2, var3
Dim SkillsArray()
j = 0
For var = 1 To lstSkills.ListCount
If lstSkills.Selected(var - 1) = True Then
ReDim Preserve SkillsArray(j)
SkillsArray(j) = lstSkills.List(var - 1)
j = j + 1
End If
Next var
If j > 20 Then
MsgBox "You have selected " & j - 20 & " more than the maximum number of 20
skills. Please unselect " & j - 20 & ""
Exit Sub
End If
k = 1
For var = 1 To lstSkills.ListCount
If lstSkills.Selected(var - 1) = True Then
ReDim Preserve SkillsArray(j)
SkillsArray(j) = lstSkills.List(var - 1)
j = j + 1
End If
Next
For var2 = 0 To UBound(SkillsArray)
ActiveDocument.FormFields("Skill" & k).Result = _
SkillsArray(var2)
k = k + 1
Next
Unload Me
End Sub
I hope someone can perhaps assist.
I am currently using the below listed code to populate 20 Text Form Field via a listbox wich is activated via a macro upon clicking on the text form field in word (The Form Fields are all in a table)
Currently In my Listbox I select either on to twenty wich will populate the necessary text form field in word , If I select more than twenty i will get a Msg Box wich will indicate that I selected to many and need to deselect. However if i deselect the records and click ok to update my text form field. I get the following error message.
Runtime Error 5941
The Requested member of the collection does not exist.
and if I select Debug it takes me to the following string
ActiveDocument.FormFields("Skill" & k).Result = _
SkillsArray(var2)
I was hoping someone could perhaps assist in what i could do to allow my text form fields to update after i receive the message. (This will only be if more than twenty records have been selected)
Private Sub cmdOK_Click()
Dim StrSkillList As String
Dim j As Long, k As Long
Dim var, var2, var3
Dim SkillsArray()
j = 0
For var = 1 To lstSkills.ListCount
If lstSkills.Selected(var - 1) = True Then
ReDim Preserve SkillsArray(j)
SkillsArray(j) = lstSkills.List(var - 1)
j = j + 1
End If
Next var
If j > 20 Then
MsgBox "You have selected " & j - 20 & " more than the maximum number of 20
skills. Please unselect " & j - 20 & ""
Exit Sub
End If
k = 1
For var = 1 To lstSkills.ListCount
If lstSkills.Selected(var - 1) = True Then
ReDim Preserve SkillsArray(j)
SkillsArray(j) = lstSkills.List(var - 1)
j = j + 1
End If
Next
For var2 = 0 To UBound(SkillsArray)
ActiveDocument.FormFields("Skill" & k).Result = _
SkillsArray(var2)
k = k + 1
Next
Unload Me
End Sub