开发者

How do you add a forms controls to a cell in a Excel spreadsheet for each row

开发者 https://www.devze.com 2022-12-22 17:30 出处:网络
How do i add a forms control in excel to a cell, I know I can draw it, but I need to make it a member 开发者_运维问答of each row and it\'s values attached to that cell/row. There are several ways to d

How do i add a forms control in excel to a cell, I know I can draw it, but I need to make it a member 开发者_运维问答of each row and it's values attached to that cell/row.


There are several ways to do this but the easiest, assuming Excel 2007 is:

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:

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. There are similar methods to the above like using the OLEObjects collection but that's just adding more pain.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号