Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2005

Tip: Looking for answers? Try searching our database.

Dropdown List of References

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Debra Ann - 16 Nov 2005 22:24 GMT
I currently have a toolbar macro that a user can select to insert a
cross-reference to an endnote that is already referenced in the document.  
What the macro does is have a pop-up box requesting the user to input the
reference number into a text box, it stores the reference in a variable, and
performs the cross-reference using the variable number.

Now the user's want to have the pop-up give them a list of the currently
available references.  Is this possible to populate a drop-down list with the
current references in the document?

Signature

Debra Ann

Bear - 17 Nov 2005 00:41 GMT
Debra Ann:

Yes. You must populate a list box with the current endnotes. This will be
similar to Word's built-in InsertCrossReference command. You can get the
collection of "referenceable" items using the GetCrossReferenceItems method
of the active document.

All you'd have to do is test the collection to pick out the endnotes.

I know this is terribly general. Let me know if you need more details.

Bear
Debra Ann - 17 Nov 2005 15:39 GMT
Yes I need more help.  I've never pulled information into a list box or combo
box before so I'm not sure how to do it.  What code would I write to pull up
all the endnotes in a combobox?  

Thanks,

Signature

Debra Ann

> Debra Ann:
>
[quoted text clipped - 8 lines]
>
> Bear
Bear - 17 Nov 2005 17:32 GMT
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
Debra Ann - 30 Nov 2005 13:51 GMT
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!

Signature

Debra Ann

> Debra Ann:
>
[quoted text clipped - 45 lines]
>
> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.