Link to home
Start Free TrialLog in
Avatar of DrTribos
DrTribosFlag for Australia

asked on

Populate UserForm List Box with Paragraph Text from MS Word Range

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
iRng.Select
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()
UF.Show

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...
ASKER CERTIFIED SOLUTION
Avatar of Faustulus
Faustulus
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DrTribos

ASKER

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

d