|

楼主 |
发表于 2025-4-12 19:45
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
本帖最后由 ning84 于 2025-4-12 20:18 编辑
FillFormat.TwoColorGradient 方法 (PowerPoint) | Microsoft Learn https://learn.microsoft.com/zh-c ... at.twocolorgradient
语法
表达式。TwoColorGradient (样式、 变体)
表达 一个代表 FillFormat 对象的变量。
参数
名称 必需/可选 数据类型 说明
样式 必需 MsoGradientStyle 渐变样式。
Variant 必需 Long 渐变变量。 可以为 1 到 4,对应于“形状填充”选项卡上的“渐变”子选项卡上的四个变体。如果 Style 为 msoGradientFromTitle 或 msoGradientFromCenter,则此参数可以是 1 或 2。
示例
本示例向 myDocument 中添加一个具有双色渐变填充效果的矩形,并设置填充的前景色和背景色。
VB
复制
Set myDocument = ActivePresentation.Slides(1)
With myDocument.Shapes.AddShape(Type:=msoShapeRectangle, Left:=0, _
Top:=0, Width:=40, Height:=80).Fill
.ForeColor.RGB = RGB(Red:=128, Green:=0, Blue:=0)
.BackColor.RGB = RGB(Red:=0, Green:=170, Blue:=170)
.TwoColorGradient Style:=msoGradientHorizontal, Variant:=1
End With
- Function StarttimeToEndtimeForStreetsnapToTexBox(Shp As PowerPoint.Shape, DateArr, FontSize1, FontSize2)
- Dim Str, EngDateStr, ChiDateStr
- Dim N1, N2
- EngDateStr = "Stree Snap From " & Format(DateArr(0), "h:mm") & " to " & Format(DateArr(1), "h:mm") & " on " & Format(DateArr(0), "mmmm d,yyyy")
- ChiDateStr = Format(DateArr(0), "yyyy年m月d日h:mm") & "到" & Format(DateArr(1), "h:mm") & "的街拍"
- With Shp
- 'If Shp.Type = 14 Then
- .TextFrame2.TextRange.Text = ChiDateStr & vbCr & EngDateStr
- N1 = Len(ChiDateStr)
- .TextFrame.TextRange.Characters(0, N1).Font.Size = FontSize1
- N2 = Len(ChiDateStr & vbCr & EngDateStr)
- .TextFrame.TextRange.Characters(N1 + 1, N2).Font.Size = FontSize2
- 'End If
- End With
- End Function
- Function ParseFilenameToDate(Str)
- Dim Arr1, Arr2, Str1, Str2
-
- Arr1 = Split(Str, "_")
- Arr2 = Split(Arr1(1), "-")
- Str1 = Arr1(0) & Arr2(0)
- Str2 = Arr1(0) & Arr2(1)
- Dim DateArr(1) As Date
- DateArr(0) = Format(Str1, "0000/00/00 00:00")
- DateArr(1) = Format(Str2, "0000/00/00 00:00")
-
- ParseFilenameToDate = DateArr
-
- End Function
- ''
- Sub L1()
- Dim Pres As PowerPoint.Presentation
- Set Pres = Application.ActivePresentation
- Dim PathName
- With Pres
- Debug.Print .Name, .Path, .FullName
- End With
- PathName = Pres.FullName
- Dim DateArr, StaartEndStr
- DateArr = ParseFilenameToDate(Left(Pres.Name, Len(Pres.Name) - 5))
- Dim Sld As Slide, Slds As Slides, SldRng As SlideRange
-
- Set Slds = Pres.Slides
- Dim Shp As Shape, Shps As Shapes
- Set SldRng = Application.ActiveWindow.Selection.SlideRange
-
- Set Shps = SldRng.Shapes
- StartEndStr = Left(Pres.Name, Len(Pres.Name) - 5)
-
- StarttimeToEndtimeForStreetsnapToTexBox Shps("Txt1"), DateArr, 14, 8
- StarttimeToEndtimeForStreetsnapToTexBox Shps("Txt2"), DateArr, 20, 15
- For ii = 1 To Shps.Count
- Set Shp = Shps(ii)
- With Shp
- Debug.Print " '" & .Name, .Type
- Debug.Print Space(8) & "arr(" & ii - 1 & ")(0) =" & .Left
- Debug.Print Space(8) & "arr(" & ii - 1 & ")(1) =" & .Top
- Debug.Print Space(8) & "arr(" & ii - 1 & ")(2) =" & .Width
- Debug.Print Space(8) & "arr(" & ii - 1 & ")(3) =" & .Height
- End With
- Next ii
-
- End Sub
- ''
- Sub Lll1()
- Dim Pres As PowerPoint.Presentation
- Set Pres = Application.ActivePresentation
-
- Dim PathName
- With Pres
- Debug.Print .Name, .Path, .FullName
- End With
- PathName = Pres.FullName
- Dim DateArr, StartEndStr
- DateArr = ParseFilenameToDate(Left(Pres.Name, Len(Pres.Name) - 5))
- Dim Sld As Slide, Slds As Slides, SldRng As SlideRange
- Dim Txt1Shp As Shape, Txt2Shp As Shape, Pic1Shp As Shape, Pic2Shp As Shape
- Dim ShpRng As ShapeRange
- Set Slds = Pres.Slides
- Dim Shp As Shape, Shps As Shapes
- For Each Sld In Slds
- Set Shps = Sld.Shapes
- StartEndStr = Left(Pres.Name, Len(Pres.Name) - 5)
- Set Txt1Shp = Shps("Txt1")
- With Txt1Shp
- StarttimeToEndtimeForStreetsnapToTexBox Txt1Shp, DateArr, 13, 10
- .Left = 420
- .Top = 50
- .Width = 220
- .Height = 100
- .Select
- With .TextFrame
- .TextRange.ParagraphFormat.Alignment = ppAlignCenter
- .AutoSize = ppAutoSizeNone
- .VerticalAnchor = msoAnchorMiddle
- End With
-
-
- End With
- Set Txt2Shp = Shps("Txt2")
- With Txt2Shp
- .Left = 420 + 260
- .Top = 50
- .Width = 220
- .Height = 100
- StarttimeToEndtimeForStreetsnapToTexBox Txt2Shp, DateArr, 13, 10
- With .TextFrame
- .TextRange.ParagraphFormat.Alignment = ppAlignCenter
- .AutoSize = ppAutoSizeNone
- .VerticalAnchor = msoAnchorMiddle
- End With
- With .Fill
- .BackColor.RGB = RGB(118, 238, 198)
- '.ForeColor.SchemeColor = ppShadow ' .ForeColor.SchemeColor = 15
- .ForeColor.RGB = RGB(230, 230, 250)
- '.BackColor.SchemeColor = ppShadow
- .TwoColorGradient msoGradientHorizontal, 3
- '.TwoColorGradient msoGradientHorizontal, 2
- Debug.Print .GradientVariant
-
- End With
- .Select
- Stop
- Stop
- End With
- Set Pic1Shp = Shps(1)
- With Pic1Shp
- .Left = 50 ' Txt1Shp.Width
- .Top = 50 'Txt2Shp.Height
- .Width = 260
- .Height = Pres.PageSetup.SlideHeight - 50 * 2
- .Select
-
-
- End With
- Set Pic2Shp = Shps(2)
- With Pic2Shp
- .Left = 420
- .Top = 200
- .Width = 500
- .Height = 300
- .Select
- End With
-
-
- For ii = 1 To Shps.Count
- Set Shp = Shps(ii)
- With Shp
- Debug.Print " '" & .Name, .Type
- Debug.Print Space(8) & "arr(" & ii - 1 & ")(0) =" & .Left
- Debug.Print Space(8) & "arr(" & ii - 1 & ")(1) =" & .Top
- Debug.Print Space(8) & "arr(" & ii - 1 & ")(2) =" & .Width
- Debug.Print Space(8) & "arr(" & ii - 1 & ")(3) =" & .Height
- End With
- Next ii
- Next Sld
- End Sub
复制代码 |
|