Drop-Down list

D

Debra Ann

I have a program that pulls up the cross-references for any existing figures
in a dropdown box. This program has not problem showing the figures if there
are 1 to 8 figures; however, if there are more than eight figures in the
document, you don't see them listed. Please let me know why you think this
is happening. Thanks,

Here is the code:


Private Sub UserForm_Initialize()
Dim varXRefs As Variant
Dim Index As Integer

Selection.Fields.Update

' Clear out any previous contents

Me.cboFigureNumber.Clear

' Load just the figures into varXRefs

varXRefs = ActiveDocument.GetCrossReferenceItems _
(ReferenceType:="Figure")

' Load the ListBox from varXRefs as an array

For Index = 1 To UBound(varXRefs)
Me.cboFigureNumber.AddItem varXRefs(Index)
Next Index

' Test whether the list has any entries and
' set command buttons accordingly

If Me.cboFigureNumber.ListCount > 0 Then
Me.cboFigureNumber.ListIndex = 0
Me.cmdInsert.Enabled = True
Else
MsgBox ("There are no figures to cross-reference.")
ReferenceFigure.Hide

End If

End Sub
 
D

Debra Ann

If I try to have msgbox(varXRefs), it comes up with an error. If I step
through the program and stop, the varXRefs(index) always gives me the correct
count. Of course, it is hard to test when you don't get the error that
others are getting. I'll have to check out their file on their system and
see what is going on. Thanks.
 
Z

zkid

Hi Debra Ann,

I'm sorry, what I meant was msgbox Ubound(varxRefs). Check to make sure
that it agrees with varxRefs(index).

I'm assuming you are not using Option Base 1 and your array starts with zero?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top