[英]How do you add a forms controls to a cell in a Excel spreadsheet for each row
我如何在Excel中添加表单控件到单元格,我知道我可以绘制它,但我需要使它成为每一行的成员,并且它的值附加到该单元格/行。
There are several ways to do this but the easiest, assuming Excel 2007 is: 有几种方法可以做到这一点,但最简单的,假设Excel 2007是:
Set cb = MyWorkSheet.CheckBoxes.Add(left, top, width, height)
cb.LinkedCell = "$A$1"
cb.Display3DShading = True
You have to experiment a little with placement as I don't think there is a direct way to align the control with a particular cell. 您必须对放置进行一些实验,因为我认为没有直接的方法将控件与特定单元格对齐。 Another way would be to use the
Shapes
collection of the worksheet: 另一种方法是使用工作表的
Shapes
集合:
Set shape = MyWorkSheet.Shapes.AddFormControl(xlCheckBox, l, t, w, h)
However, keep in mind that the above method returns a Shape
object and not a CheckBox
object so you can't manipulate its properties directly. 但是,请记住,上面的方法返回一个
Shape
对象而不是CheckBox
对象,因此您无法直接操作其属性。 There are similar methods to the above like using the OLEObjects
collection but that's just adding more pain. 有类似的方法,如使用
OLEObjects
集合,但这只是增加了更多的痛苦。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.