使用VBA获取ActiveX组合框的选定值 [英] Get the selected value of a activex combobox using vba

查看:479
本文介绍了使用VBA获取ActiveX组合框的选定值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取组合框的选定值?

How do i get the selected value of the combobox?

我有一个组合框,其值是:公司"和消费者".

i have a combobox which has the values: "Corporate" and "Consumer".

我想获取我选择的值而不是索引,并存储在字符串中.

I want to get the value that i selected, not the index, and store in a string.

类似这样的东西:

 string a = combobox.value;

(一个->消费者)

谢谢

推荐答案

如果您的ComboBox嵌入在电子表格中,则可以使用以下方法:

If your ComboBox is embedded in a spreadsheet you can use this:

Dim ws as Worksheet
Dim cboCorpConsumer as ComboBox
Dim a as String

Set ws = Worksheets("YourWorksheetName")
Set cboCorpConsumer = ws.OLEObjects("cboNameFromActiveXProperties").Object

a = cboCorpConsumer.Value

或一行:

a = Worksheets("YourWorksheetName").OLEObjects("cboNameFromActiveXProperties").Object.Value

这篇关于使用VBA获取ActiveX组合框的选定值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆