Jake Johnson
08-12-2012, 09:27 AM
I'm now taking the next step and wanting to use a list of first words in long sentences to populate a column in a user form's listbox.
The following code seems as though it should work but it returns the error message "Could not set the RowSource property. Invalid property value." Not sure where I've gone wrong. The required value for a RowSource is a string, and I'm sending a string to it. Suggestions?
Sub FindStartOfLongSentenesAndPutInUserForm()
'This should list the first word of each sentence longer than 10 words in a user form Listbox
Dim asentence As Range
Dim str As String
For Each asentence In ActiveDocument.Range.Sentences
If asentence.Words.Count > 10 Then
str = str & asentence.Words(1)
End If
Next
With UserForm1
.ListBox1.RowSource = str
End With
End Sub
The following code seems as though it should work but it returns the error message "Could not set the RowSource property. Invalid property value." Not sure where I've gone wrong. The required value for a RowSource is a string, and I'm sending a string to it. Suggestions?
Sub FindStartOfLongSentenesAndPutInUserForm()
'This should list the first word of each sentence longer than 10 words in a user form Listbox
Dim asentence As Range
Dim str As String
For Each asentence In ActiveDocument.Range.Sentences
If asentence.Words.Count > 10 Then
str = str & asentence.Words(1)
End If
Next
With UserForm1
.ListBox1.RowSource = str
End With
End Sub