|
楼主 |
发表于 2023-2-1 14:55
|
显示全部楼层
ShapeRange 对象 (PowerPoint) | Microsoft Learn https://learn.microsoft.com/zh-cn/office/vba/api/powerpoint.shaperange
花了好长时间,也没有学会,ShapeRange怎么用。
Set myDocument = ActivePresentation.Slides(1)myDocument.Shapes.Range(Array(1, 3)).Fill _ .Patterned msoPatternHorizontalBrick
- Sub ll()
- Dim Ppt As PowerPoint.Application
- Dim Pres As Presentation
- Dim Sld As Slide
- Dim Shp As Shape
- Dim ShpRng As ShapeRange
- Dim TxtRng As TextRange
- Dim TxtFrm As TextFrame
- Dim TxtEFrm As TextEffectFormat
- Dim TxtSty As TextStyle
- Set Ppt = New PowerPoint.Application
- Set Pres = Ppt.ActivePresentation
- Set Sld = Pres.Slides(1)
- For Each Shp In Sld.Shapes
- If Shp.Type = msoTextBox Then
- Set TxtFrm = Shp.TextFrame
- If TxtFrm.HasText = True Then
- Set TxtRng = TxtFrm.TextRange
- Debug.Print TxtRng.Text
- Shp.TextFrame.TextRange.Text = "层级太多太复杂"
- With Shp
- .Left = 100
- .Top = 350
- .Width = 300
- Debug.Print .Left, .Top
- End With
- ''
- With TxtFrm
- .Orientation = msoTextOrientationVerticalFarEast
- .Orientation = msoTextOrientationHorizontal
- .WordWrap = msoTrue
- With .TextRange
- Debug.Print .Length, .BoundLeft, .BoundWidth
- Debug.Print .Font.Shadow
- .Font.Shadow = msoFalse
- .Font.Size = 30
- End With
- End With
- TxtFrm.TextRange.Font.Color.RGB = RGB(255, 255, 255)
- 'Set ShpRng = Sld.Shapes(1).Range(1)
- Debug.Print Sld.Shapes.Range
- Sld.Shapes.Range(Array(1, 3)).Fill.Patterned msoPatternHorizontalBrick
- Stop
- ''
- End If
- End If
- Next Shp
- End Sub
- Sub Macro1()
- '
- ' 宏由 win 记录,日期: 2023/2/1
- '
- ActiveWindow.Selection.SlideRange.Shapes("Text Box 39").Select
- With ActiveWindow.Selection.ShapeRange
- .IncrementLeft -0.88
- .IncrementTop -0.62
- End With
- ActiveWindow.Selection.SlideRange.Shapes("Object 23").Select
- ActiveWindow.Selection.SlideRange.Shapes("Text Box 39").Select
- With ActiveWindow.Selection.ShapeRange
- .Fill.Visible = msoTrue
- .Fill.Solid
- .Fill.ForeColor.RGB = RGB(153, 204, 255)
- .Fill.Transparency = 0#
- .Line.Visible = msoTrue
- .Line.ForeColor.SchemeColor = ppForeground
- .Line.BackColor.RGB = RGB(255, 255, 255)
- End With
- ActiveWindow.Selection.SlideRange.Shapes("Text Box 39").Select
- ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Select
- ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Characters(Start:=1, Length:=8).Select
- With ActiveWindow.Selection.TextRange.Font
- .NameAscii = "Arial"
- .NameOther = "Arial"
- .NameFarEast = "华文行楷"
- .Size = 30
- .Bold = msoTrue
- .Italic = msoFalse
- .Underline = msoFalse
- .Shadow = msoFalse
- .Emboss = msoFalse
- .BaselineOffset = 0
- .AutoRotateNumbers = msoTrue
- .Color.SchemeColor = ppForeground
- End With
- ActiveWindow.Selection.SlideRange.Shapes("Object 23").Select
- ActiveWindow.Selection.SlideRange.Shapes("Text Box 39").Select
- With ActiveWindow.Selection.ShapeRange
- .Fill.Transparency = 0#
- .Line.Weight = 1.5
- .TextFrame.Orientation = msoTextOrientationVerticalFarEast
- End With
- ActiveWindow.Selection.Unselect
- End Sub
复制代码
|
|