ControlFormat.ListIndex运行时错误Excel 2007 [英] ControlFormat.ListIndex runtime error Excel 2007

查看:232
本文介绍了ControlFormat.ListIndex运行时错误Excel 2007的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在工作表上研究一个列表框(Form Control)的问题。我需要知道Office 2007和2010以及其后的处理方式是否不一样。

I'm trying to research an issue with a listbox (Form Control) on a worksheet. I need to know if it is handled different in office 2007 and 2010 and later.

在Excel 2007中,将SheetControl ListBox添加到sheet1,并将其填入一些随机值。
验证选择类型是否设置为单个,并在标准模块中运行以下代码:

In Excel 2007, add a FormControl ListBox to sheet1, and fill it with some random values. Verify that the selection type is set to single and run the following code in a standard module:

Sub TestListIndexExcel2007()
    Debug.Print ThisWorkbook.Worksheets(1).Shapes(1).ControlFormat.ListIndex
End Sub

立即窗口应该返回列表框中所选项目的索引,到目前为止没有问题。

The immediate window should return the index of the selected item in the listbox, so far no problem.

现在设置列表框的选择类型到多个或扩展,但只选择列表框中的1个项目,并再次运行子上面。我需要知道它是否在下面生成错误,或者如果它仍然在Excel 2007中抛出一个listindex。

Now set the selectiontype of the listbox to Multi or Extend but only select 1 item in the listbox and run the sub above again. I need to know if it generates the error below or if it still spits out a listindex in Excel 2007.


运行时错误'1004 ':

Run-time Error '1004':

无法获取ListBox类的ListIndex属性

Unable to get the ListIndex property of the ListBox class

我会自己测试一下,但是我无法访问Office 2007。

I would test this myself but I don't have access to Office 2007.

推荐答案

没有。你会得到的第一个错误是438错误,因为 Shape 没有一个 FormControl 属性。如果您用 ControlFormat 替换,那么是的,您将收到1004错误。

No it doesn't. The first error you will get is a 438 error since a Shape doesn't have a FormControl property. If you replace that with ControlFormat then yes you'll get a 1004 error.

这篇关于ControlFormat.ListIndex运行时错误Excel 2007的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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