我有一些组和按钮附加到数据透视表。我想将所有这些设置为不移动并使用单元格调整大小。我正在使用下面的代码来完成此任务。这适用于组,但不访问组内的按钮。
这些按钮位于嵌套组中。如何访问这些组中的按钮?
我试过
Sheet1.Shapes.SelectAll
Selection.UnGroup
..在代码开头清除所有组。这允许我更新嵌套在组中的按钮。如果不首先清除页面上的所有组,我将如何以不同方式编码以访问各组中的按钮?
Group 26 (A group containing slicers and buttons)
Group box 28 (A Form Control Group Box)
Group 24 (A Grouping of the buttons)
btn_do_this
btn_do_that
任何想法??
Private Sub Cmd_Move_and_size_Click()
Dim sh As Shape
Dim StrText As String
For Each sh In ActiveSheet.Shapes
' If sh.Type = 12 Then sh.Visible = True 'show button!
' Debug.Print (CStr(sh.Type) + " " + sh.Name
StrText = " Shape will not move and size with cells"
If sh.Placement <> xlFreeFloating Then
sh.Placement = xlFreeFloating
Else
sh.Placement = xlMoveAndSize
StrText = " Shape WILL move and size with cells"
End If
Next
MsgBox StrText
End Sub