如何通过计数将形状添加到各部分之间的幻灯片

发布于 2025-01-11 04:01:01 字数 587 浏览 0 评论 0原文

我正在尝试在各部分之间的幻灯片中添加形状(将部分编号作为形状中的文本),但到目前为止我只知道如何找到具有该布局名称的形状。我想我应该在某个地方设置一个计数器,但我还没有找到方法。 理想情况下,我会对这些部分进行计数,然后将值传递给要开发的宏的其他部分。

Sub Navigator()

Dim oSlide As Slide
Dim oSlideNavigator As Slide
Dim oShapeNavigator As Shape
Dim Section_N As Integer



    For Each oSlide In ActivePresentation.Slides
        If oSlide.CustomLayout.Name = "Section" Then
        Set oShapeNavigator = oSlide.Shapes.AddTable(2, 2, Left:=10, Top:=10, Width:=200, Height:=2)
            oShapeNavigator.Fill.ForeColor.RGB = RGB(255, 128, 128)

        End If
    Next
End Sub
 

I am trying to add shapes to the slides between sections (with the section number as text in the shape) but I know so far only how to find those with that layout name. I think I should setup a counter somewhere but I have not found a way how.
Ideally I would count the sections and then pass the value later to other parts of the macro to be developed.

Sub Navigator()

Dim oSlide As Slide
Dim oSlideNavigator As Slide
Dim oShapeNavigator As Shape
Dim Section_N As Integer



    For Each oSlide In ActivePresentation.Slides
        If oSlide.CustomLayout.Name = "Section" Then
        Set oShapeNavigator = oSlide.Shapes.AddTable(2, 2, Left:=10, Top:=10, Width:=200, Height:=2)
            oShapeNavigator.Fill.ForeColor.RGB = RGB(255, 128, 128)

        End If
    Next
End Sub
 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

别忘他 2025-01-18 04:01:01

我使用布局名称“Section”为每张幻灯片设置计数器,然后将值发送到表以添加到与找到的值不同的值中。所以一个简单的Else就达到了目的。

Sub NavigatorX()

'Dim SectionXArr() As Long
Dim oSlide As Slide

Dim SectionX As Slide
Dim SectionXArr As SlideRange ' was ReDim
Dim oShapeNavigator As Shape
Dim NavSlide As Slide
Dim nCounter As Long
'Dim NavSlides

Dim iRow As Integer
Dim iColumn As Integer

For Each oSlide In ActivePresentation.Slides

    If oSlide.CustomLayout.Name = "Section" Then
        nCounter = nCounter + 1
        
        ElseIf nCounter > 0 Then
            Set oShapeNavigator = oSlide.Shapes.AddTable(1, 1, Left:=10, Top:=10, Width:=200, Height:=2)
        oShapeNavigator.Fill.ForeColor.RGB = RGB(255, 128, 128)
        With oShapeNavigator.Table

            For iRow = 1 To .Rows.Count
            For iColumn = 1 To .Columns.Count
                    With .Cell(iRow, iColumn).Shape.TextFrame.TextRange
                        .Text = "Section " & nCounter
                    With .Font
                        .Name = "Bahnschrift SemiBold Condensed (Headings)"
                        .Size = "14"
                    End With
                    End With
            Next iColumn
            Next iRow
        End With

        
    End If

Next oSlide

End Sub

I Set the counter for each slide with Layout Name "Section", then sent the value to the table to be added in those different from those found. So a simple Else did the trick.

Sub NavigatorX()

'Dim SectionXArr() As Long
Dim oSlide As Slide

Dim SectionX As Slide
Dim SectionXArr As SlideRange ' was ReDim
Dim oShapeNavigator As Shape
Dim NavSlide As Slide
Dim nCounter As Long
'Dim NavSlides

Dim iRow As Integer
Dim iColumn As Integer

For Each oSlide In ActivePresentation.Slides

    If oSlide.CustomLayout.Name = "Section" Then
        nCounter = nCounter + 1
        
        ElseIf nCounter > 0 Then
            Set oShapeNavigator = oSlide.Shapes.AddTable(1, 1, Left:=10, Top:=10, Width:=200, Height:=2)
        oShapeNavigator.Fill.ForeColor.RGB = RGB(255, 128, 128)
        With oShapeNavigator.Table

            For iRow = 1 To .Rows.Count
            For iColumn = 1 To .Columns.Count
                    With .Cell(iRow, iColumn).Shape.TextFrame.TextRange
                        .Text = "Section " & nCounter
                    With .Font
                        .Name = "Bahnschrift SemiBold Condensed (Headings)"
                        .Size = "14"
                    End With
                    End With
            Next iColumn
            Next iRow
        End With

        
    End If

Next oSlide

End Sub
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文