Solved

Accessing Excel combo box from VB.NET

Posted on 2015-02-23
11
64 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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

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 45

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
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 …
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

743 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

11 Experts available now in Live!

Get 1:1 Help Now