Solved

Accessing Excel combo box from VB.NET

Posted on 2015-02-23
11
70 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
11 Comments
 
LVL 34

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 34

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
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 

Author Comment

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

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
 

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 34

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 34

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 47

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

Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

Use Windows Task Scheduler to print a Word document weekly so your printer ink won't dry out.
I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

729 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