PC Review


Reply
Thread Tools Rate Thread

ComboBox .List problem

 
 
=?Utf-8?B?Q3JhaWc=?=
Guest
Posts: n/a
 
      8th Aug 2007
I'm using VB6 to create Excel files and add .bas files to it. From VB6, I'm
running a subroutine (macro) in the Excel file (it belongs to a .bas file I
just added) that adds an Excel Forms combobox to a sheet and sets its source
to a named range on another sheet. Here's the code snippet I'm running:
Set CB = WS.DropDowns.Add(Left, Top, 128.25, 15.75) '(Left, Top, Width,
Height)
With CB
.Name = Name
.ListFillRange = Source
.ListIndex = 0
.DropDownLines = 8
.Display3DShading = False
.OnAction = Name & "_Change"
End With

This all appears to be working (except the .ListIndex is not actually
setting the text of the combobox to the first value - this is not my real
problem).
Next, I'm running the Change event of the combobox I just added (I also
added the Change event subroutine through code, in case that matters). In it
I have the following line:
SelectedValue =
WS.DropDowns("cmbServices").List(WS.DropDowns("cmbServices").ListIndex)
When I'm in VB6 running this as a macro, the above line errors off saying
"Unable to get the List property of the DropDown class". However, if I save
the Excel file and open it, then this line of code works perfectly.
Any ideas?
Thx.
 
Reply With Quote
 
 
 
 
=?Utf-8?B?Q3JhaWc=?=
Guest
Posts: n/a
 
      8th Aug 2007
One other note is that the second part of the line is working. In
SelectedValue =
WS.DropDowns("cmbServices").List(WS.DropDowns("cmbServices").ListIndex)
The WS.DropDowns("cmbServices").ListIndex does contain a value of zero. So,
it does see the object.
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Combobox list based on choice in previous combobox Slim Slender Microsoft Excel Programming 0 2nd Aug 2011 11:16 AM
Limit ComboBox list by previous ComboBox results David Microsoft Access Form Coding 1 7th Aug 2009 07:09 PM
Problem with combobox and list =?Utf-8?B?SmF5RGU=?= Microsoft Access Form Coding 4 28th Jun 2006 05:15 PM
combobox not on list problem? Anne Microsoft Access Form Coding 3 7th Sep 2004 01:58 AM
Values contained in value list of second combobox based on value selected in first combobox. Anthony Microsoft Access Forms 16 6th Mar 2004 04:07 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:46 AM.