无法将相同的项目两次添加到CustomProperties?
我试图使用ActiveSheet.CustomProperties
临时存储我的macros的每个工作表的设置。 似乎不可能将两个相同名称的项目添加到该集合中。 为什么?
由于每个项目都由一个索引号标识(您通过指定其索引号: ActiveSheet.CustomProperties.Item(1).Name
)来读取一个属性,所以没有明显的原因可以阻止添加具有相同名称的项目你要。
我的代码很简单:
ActiveSheet.CustomProperties.Add "foobar", 1
它第一次工作,但我第二次得到以下错误:
错误9:下标超出范围
提前致谢。
是的,你不能添加两次。 你可以使用这个代码
Sub sample() On Error Resume Next ActiveSheet.CustomProperties(1).Delete On Error GoTo 0 ActiveSheet.CustomProperties.Add "foobar", 1 End Sub