Solved

Accessing Excel combo box from VB.NET

Posted on 2015-02-23
11
65 Views
Last Modified: 2016-02-12
Trying to figure out how to use vb.net and miscrosoft.office.interop.excel to read the named range from an embedded combo box in excel. I have no clue where to even begin. Any help would greatly be appreciated.
0
Comment
Question by:ProgrammingIsFun
  • 5
  • 4
11 Comments
 
LVL 33

Expert Comment

by:Norie
ID: 40626897
Are you opening the Excel workbook with the combobox?

How was the combobox created and where is it located?
0
 

Author Comment

by:ProgrammingIsFun
ID: 40627250
Hey,
I'm working with the amazon browse tree guide. The embedded combo box comes with the excel spreadsheet from amazon. I am opening up the xls file programmatically and reading the data. One of the columns is an embedded combo box where each has its own named range. I need to find the coordinates of each named range combo box. What should I do?
0
 
LVL 33

Expert Comment

by:Norie
ID: 40627300
If you are working with an Excel workbook there are 2 types of comboboxes you can have on a worksheet - Forms and ActiveX.

You can access a Forms control via the Shapes collection of the sheet and an ActiveX control can be accessed via the OLEOBject collection of the sheet.
0
 

Author Comment

by:ProgrammingIsFun
ID: 40627344
How can I tell if it's a forms or activex control?
0
 
LVL 33

Expert Comment

by:Norie
ID: 40627350
If you select the combobox and right click you'll see Assign Macro... as an option in the context menu if it's a Forms control, if it's an ActiveX button you'll see Properties (and View Code) as one of the options.
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:ProgrammingIsFun
ID: 40630283
I have finally figured out that I am not asking the right question.  Let's try again.  I need to read the source (named range) of a data validation list in excel using vb.net .
0
 
LVL 33

Accepted Solution

by:
Norie earned 500 total points
ID: 40630295
It's not really the wrong question, it's more like a different type of dropdown.:)

In VBA we would use this code to get the named range of the data validation of cell A1.
    strName = Range("A1").Validation.Formula1

Open in new window


The code for VB.Net shouldn't look much different.
0
 

Author Comment

by:ProgrammingIsFun
ID: 40631174
Oh, that was perfect.  One more question. How can I determine, using vba, if a cell is a data validation list.  Most of the items in the cells in the column are data validation list are, but a few are not.  Thanks.
0
 
LVL 33

Expert Comment

by:Norie
ID: 40631207
What you could do is use SpecialCells(xlCellTypeAllValidation) for the column.

That should return all the cells in the column that have data validation.

If you want to find cells that have the same validation you can use xlCellTypeSameValidation.
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 40684226
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Outlook Free & Paid Tools
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now