本帖最后由 ning84 于 2023-2-18 21:44 编辑
图形-Shapes-ExcelHome https://www.excelhome.net/87.html
- Sub del1()
- Dim Arr
- Dim oLeft, oTop, oWidth, oHeight, mLeft
- Dim Shp As Shape
- Dim TxtFrm As TextFrame
- Dim TxtFrm2 As TextFrame2
- Dim ArrMsoAutoShapeType, ArrMso2007
- Dim ArrMsoThemeColorSchemeIndex
- ArrMsoAutoShapeType = Array(149, 150, 94, 95, 96, 91, 92, 147, 148, 93, 129, 131, 125, 134, 132, 130, 127, 126, 128, 136, 133, 135, 25, 137, 41, 44, 15, 20, 13, 182, 181, 180, 52, 161, 60, 179, 108, 162, 169, 11, 14, 48, 100, 46, 45, 47, 99, 144, 141, 4, 146, 18, 27, 26, 104, 36, 56, 98, 89, 90, 62, 75, 79, 73, 64, 63, 84, 87, 88, 67, 81, 66, 86, 71, 72, 82, 68, 139, 74, 78, 65, 70, 61, 76, 85, 80, 83, 77, 69, 16, 158, 174, 172, 173, 159, 21, 145, 10, 102, 7, 34, 54, 31, 29, 176, 37, 57, 177, 140, 40, 43, 22, 109, 113, 121, 117, 110, 114, 122, 118, 111, 115, 123, 119, 112, 116, 124, 120, 183, 166, 167, 164, 165, 168, 163, -2, 24, 143, 19, 50, 138, 6, 9, 107, 2, 51, 142, 175, 28, 171, 39, 59, 1, 105, 12, 33, 53, 32, 30, 8, 151, 157, 152, 5, 106, 17, 155, 157, 156, 154, 170, 49, 23, 178, 160, 3, 35, 55, 38, 58, 97, 42, 101, 103)
- Debug.Print UBound(ArrMsoAutoShapeType)
- ''
- ArrMso2007 = Array(94, 95, 96, 91, 92, 93, 129, 131, 125, 134, 132, 130, 127, 126, 128, 136, 133, 135, 25, 137, 41, 44, 15, 20, 13, 52, 60, 108, 11, 14, 48, 100, 46, 45, 47, 99, 4, 18, 27, 26, 104, 36, 56, 98, 89, 90, 62, 75, 79, 73, 64, 63, 84, 87, 88, 67, 81, 66, 86, 71, 72, 82, 68, 74, 78, 65, 70, 61, 76, 85, 80, 83, 77, 69, 16, 21, 10, 102, 7, 34, 54, 31, 29, 37, 57, 40, 43, 22, 109, 113, 121, 117, 110, 114, 122, 118, 111, 115, 123, 119, 112, 116, 124, 120, -2, 24, 19, 50, 138, 6, 9, 107, 2, 51, 28, 39, 59, 1, 105, 12, 33, 53, 32, 30, 8, 5, 106, 17, 49, 23, 3, 35, 55, 38, 58, 97, 42, 101, 103)
- Arr = Array(94, 95, 96, 91, 92, 93, 129, 131, 125, 134, 132, 130, 127, 126, 128, 136, 133, 135, 25, 137, 41, 44, 15, 20, 13, 52, 60, 108, 11, 14, 48, 100, 46, 45, 47, 99, 4, 18, 27, 26, 104, 36, 56, 98, 89, 90, 62, 75, 79, 73, 64, 63, 84, 87, 88, 67, 81, 66, 86, 71, 72, 82, 68, 74, 78, 65, 70, 61, 76, 85, 80, 83, 77, 69, 16, 21, 10, 102, 7, 34, 54, 31, 29, 37, 57, 40, 43, 22, 109, 113, 121, 117, 110, 114, 122, 118, 111, 115, 123, 119, 112, 116, 124, 120, -2, 24, 19, 50, 138, 6, 9, 107, 2, 51, 28, 39, 59, 1, 105, 12, 33, 53, 32, 30, 8, 5, 106, 17, 49, 23, 3, 35, 55, 38, 58, 97, 42, 101, 103)
- ''
- ArrMsoThemeColorSchemeIndex = Array(5, 6, 7, 8, 9, 10, 1, 3, 12, 11, 2, 4)
- ''
- For Each Shp In Sheet3.Shapes
- Shp.Delete
- Next Shp
-
- With Sheet3.Shapes
- oLeft = 5
- oTop = 5
- oWidth = 300
- oHeight = 30
- For ii = 0 To UBound(Arr)
- Set Shp = .AddShape(Arr(ii), oLeft, oTop, oWidth, oHeight)
- Set TxtFrm2 = Shp.TextFrame2
- oLeft = mLeft
- With TxtFrm2
- .TextRange.Text = Shp.Name & oLeft & " x " & oTop & "x" & oWidth & " x " & oHeight
- .AutoSize = msoAutoSizeShapeToFitText
- End With
- ''
- oLeft = oLeft + oWidth + 50
- Set Shp = .AddShape(Arr(ii), oLeft, oTop, oWidth + 50, oHeight)
- Set TxtFrm = Shp.TextFrame
- With TxtFrm
- .Characters.Text = Shp.Name & oLeft & " x " & oTop & " x " & oWidth + 50 & " x " & oHeight
- .AutoSize = True
- End With
- oTop = oTop + oHeight + 40
- oLeft = mLeft
- Next ii
- End With
- End Sub
复制代码
MsoAutoShapeType 枚举 (Office) | Microsoft Learn https://learn.microsoft.com/zh-c ... ce.msoautoshapetype
眉毛都有数根白眉毛,头发基本全白的老汉,近期有点开窍。能编制有点难度的小程序。
小程序也就30多行代码。关键语句2条,Set Shp = .AddShape(Arr(ii), oLeft, oTop, oWidth, oHeight), Set TxtFrm2 = Shp.TextFrame2
数据源简化为数组,简化编程工作量。 |