0

我想查看视频是否已链接或未使用 vba。为此,我检查了形状的参数,发现我的视频已链接 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
4

1 回答 1

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
于 2013-07-19T14:57:27.520 回答