RE: Dropdown List of References by DebraAnn
DebraAnn
Wed Nov 30 07:51:11 CST 2005
Bear:
I'm sorry it took so long to get back. I had a corrupted cache and
everytime I came out to the website to see if you had responded, I got a
"Service Temporarily Unavailable." I assumed the website was done but
finally figured out my cache was corrupted and kept showing the same screen
when I went out to the newsgroup.
Anyways ... the code worked great. I struggled by my self for quite a few
days and had one item in but needed to do the loop to get the rest of the
items listed. I can't thank you enough.
When I wrote to Microsoft about the problem I was having, I told them I was
lost without all of you. You all make my life so much easier; and, although
I always appreciated you all, I never appreciated you all as much as I did
when I didn't have access to the newsgroup.
Have a great day!
--
Debra Ann
"Bear" wrote:
> Debra Ann:
>
> Let's assume you have a UserForm with a ListBox called lstEndnote, and a
> command button called cmdInsert. You'll also need a variant field to get the
> cross-references. Say we call this varXRefs.
>
> Here's some code that would populate the ListBox with just the endnotes. It
> also enables or disables the cmdInsert button based on whether or not the
> active document has any endnotes. You'd have to write the code for the rest
> of the UserForm controls, but I don't want to leave you without challenges.
>
> Let me know if you get stuck.
>
> Bear
>
>
> Sub UpdateEndnoteList()
>
> ' Fill lstEndnote with the endnotes from the
> ' active document
>
> Dim varXRefs As Variant
> Dim Index As Integer
>
> ' Clear out any previous contents
>
> Me.lstEndnote.Clear
>
> ' Load just the endnotes into varXRefs
>
> varXRefs = ActiveDocument.GetCrossReferenceItems _
> (ReferenceType:=wdRefTypeEndnote)
>
> ' Load the ListBox from varXRefs as an array
>
> For Index = 1 To UBound(varXRefs)
> Me.lstEndnote.AddItem varXRefs(Index)
> Next Index
>
> ' Test whether the list has any entries and
> ' set command buttons accordingly
>
> If Me.lstEndnote.ListCount > 0 Then
> Me.lstEndnote.ListIndex = 0
> Me.cmdInsert.Enabled = True
> Else
> Me.cmdInsert.Enabled = False
> End If
>
> End Sub
>