我想看看是否使用vba链接视频。为此,我检查形状的参数,我看到我视频链接LinkFormat参数是启用,如果它没有被禁用。问题是,如果我检查LinkFormat不是链接视频,我会收到错误“对象不存在”。我只是想在没有错误的情况下检查它是否存在。
我尝试放错误处理程序,但无论如何它给了我错误。
编辑:在这里,我将如何尝试使用我在这篇文章中收到的建议:
For Each sld In ActivePresentation.Slides
For i = 1 To sld.Shapes.count
If sld.Shapes(i).Type = msoMedia Then
If hasVideo = False Then
hasVideo = True
End If
videoNum = videoNum + 1
If sld.Shapes(i).MediaType = ppMediaTypeMovie Then
If CSng(Application.Version) < 14 Then
If hasVideo = False Then
hasVideo = True
End If
videoNum = videoNum + 1
Else
If sld.Shapes(i).MediaFormat.IsEmbedded Then
If hasVideo = False Then
hasVideo = True
End If
videoNum = videoNum + 1
Else
MsgBox "linked videos are not supported and won't be shown"
End If
End If
End If
End If
Next i
Next
答案 0 :(得分:0)
Sub TestVideos()
' oSh as Object rather than as Shape so it'll work
' in earlier versions of PPT that don't have some of these
' properties
Dim oSh As Object
Dim oSl As Slide
' because my test file has two videos
' on slide 1 ...
Set oSl = ActivePresentation.Slides(1)
For Each oSh In oSl.Shapes
If oSh.Type = msoMedia Then
If oSh.MediaType = ppMediaTypeMovie Then
If CSng(Application.Version) < 12 Then
' This is PPT 2003 or earlier; all vids are embedded
MsgBox "This video is embedded"
Else
If oSh.MediaFormat.IsEmbedded Then
MsgBox "This video is embedded"
Else
MsgBox "This video is linked"
End If
End If
End If
End If
Next
End Sub