|
|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
我的这个代码做成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
|
|