Populate UserForm List Box with Paragraph Text from MS Word Range

DrTribos used Ask the Experts™
Hi All

Seasons Greetings :-D

I am struggling with something that I thought would be close to simple...  Populate a userform listbox with text from a specified range in a document.  Each entry should be a single paragraph...  (ideally I'd also like the paragraph number to show up; I'm using a list style).

Private Sub UserForm_Initialize()  '  <<<< code in user form (UF)
Dim iRng As Range  ' this is defined by a bookmark
Dim parra As Paragraph
Dim pText As String

With ActiveDocument
Set iRng = ActiveDocument.Bookmarks("iTxt").Range   ' works, the range is selected
For Each parra In iRng   ' <<<<  No matter what I do here the code fails with an unhelpful message
pText = parra.Range.Text
 RefListBox.AddItem (pText)

Next parra
End With
End Sub

Open in new window

There is a sub to call this...

Sub myUF()

End Sub

Open in new window

The error message is:
Run-time error '438'
Object doesn't support this property or method

When I try to debug the line UF.show is higlighted...
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
The For .. Each loop sorts through a collection, to be precise, the collection of paragraphs in iRng. It can't sort through iRng because iRng isn't a collection. Therefore, please try
For Each parra In iRng.Paragraphs

Open in new window


Thank you for the solution (which has been driving me nuts) and your explanation which I hope to apply in the future!


Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial