Excel表格模板下载与分享

zzpsx Lv.4

关注
我的这个代码做成ppt加载项后,重启ppt无法使用

Sub ppt加页码()
    Dim Width As Single, Height As Single, shp As Shape, n As Long, i As Long, sld As Slide
    With ActivePresentation
        Width = .PageSetup.SlideWidth '幻灯片的宽度
        Height = .PageSetup.SlideHeight '幻灯片的高度
        n = .Slides.Count  '计算幻灯片的总数
        On Error GoTo 0
        For i = 1 To n '从第1页开始添加
        On Error Resume Next
        .Slides(i).Shapes("PageShape").Delete
        Set shp = .Slides(i).Shapes.AddTextbox(msoTextOrientationHorizontal, Width - 300, Height - 70, 30, 48)
        '水平文本框,左边距,顶边距,高度,宽度
        With shp
            .Name = "PageShape"
            .TextFrame.WordWrap = msoFalse
            .TextFrame.TextRange.Text = "第" & i & "页,共" & n & "页"           '页码
            .TextFrame.TextRange.Font.NameAscii = "黑体"
            .TextFrame.TextRange.Font.NameFarEast = "黑体"
            .TextFrame.TextRange.Font.Size = 42   '字号
            .TextFrame.TextRange.Font.Color.RGB = RGB(Red:=255, Green:=0, Blue:=0)
        End With
            With ActivePresentation
        For Each sld In .Slides
            With sld.SlideShowTransition
                .SoundEffect.Name = "抽气"
            End With
        Next
    End With
        Next
    End With
End Sub

334阅读
1回复 倒序

zzpsx 楼主 2楼

重启ppt后点击代码按钮,出现以下弹窗。但是所有设置都启用了宏。
image.png

已显示全部内容