【发布时间】:2018-08-04 02:55:58
【问题描述】:
我有一个宏,当我到达特定幻灯片时应该运行该宏。现在,当我在幻灯片编辑器视图中而不是在实际幻灯片视图中时,宏可以完美运行。但是当我在幻灯片查看时,宏只运行一半的代码。我一生都无法弄清楚,任何帮助将不胜感激!
Private Sub NewMonthButton_Click()
Dim s As Shape
Dim Month As String
'NewMonthSelection is a text box from a user form
Month = NewMonthSelection.Text
'Delete any images on the slide
For Each s In ActivePresentation.Slides(7).Shapes
If s.Type = 13 Then s.Delete '13 is msoPicture
Next
'Add first picture
ActivePresentation.Slide(7).Shapes.AddPicture( _
FileName:="C:\Users\Public\Pictures\Sample Pictures\" & Month & "1.PNG", _
LinkToFile:=msoFalse, _
SaveWithDocument:=msoTrue, Left:=80, Top:=120, _
Width:=550, Height:=180).Select
'This is where the code quits, it adds the first picture but not the second
'unless its in the slide editor view
ActivePresentation.Slide(7).Shapes.AddPicture( _
FileName:="C:\Users\Public\Pictures\Sample Pictures\" & Month & "2.PNG", _
LinkToFile:=msoFalse, _
SaveWithDocument:=msoTrue, Left:=80, Top:=310, _
Width:=550, Height:=180).Select
NewMonthSelection.Text = ""
End Sub
【问题讨论】:
标签: vba powerpoint