为什么我无法从 Excel 工作表中删除这个讨厌的下拉列表?
我正在尝试使用以下代码从电子表格中删除下拉菜单:
Dim objShape As Shape
For Each objShape In ActiveSheet.Shapes
objShape.Delete
Next
但 objShape 返回应用程序定义或对象定义错误
:
Debug.Print objShape。 FormControlType
返回 xlDropDown
调试.Print objShape.Name
返回“下拉 250”
Debug.Print objShape.TopLeftCell
返回应用程序定义或对象定义的错误
ActiveSheet.Cells.Validation.Delete
并不能消除它,使用 ShapeRange
也不能消除它。
任何关于如何根除这个小家伙的建议将不胜感激。
I am trying to delete a drop down from a spreadsheet using the following code:
Dim objShape As Shape
For Each objShape In ActiveSheet.Shapes
objShape.Delete
Next
But objShape
returns Application-Defined or Object-Defined Error
:
Debug.Print objShape.FormControlType
returns xlDropDown
Debug.Print objShape.Name
returns "Drop Down 250"
Debug.Print objShape.TopLeftCell
returns Application-Defined or Object-Defined Error
ActiveSheet.Cells.Validation.Delete
does not get rid of it, nor does using ShapeRange
.
Any suggestions on how to eradicate this little bugger would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
几个想法:
Couple of ideas:
下拉列表与工作簿中的另一张工作表相关联。删除另一张纸后,代码正确删除了形状。
The drop down list was tied to another sheet in the workbook. After deleting the other sheet, the code correctly deleted the shape.