2013-07-19 23 views
0

我想查看视频是否使用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

显示你的代码,如果可能的话... – dee

回答

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 
+0

得益于它完美! –

+0

最后,我发现了一个在这些行中给我一个错误的简报。它在其他如果CSng(Application.Version)<12和其他如果oSh.MediaFormat.IsEmbedded它然后它给我一个错误,因为MediaFormat不存在。 –

+0

我的错误:应该是<14而不是<12。14 = PPT 2010,第一个开始嵌入视频的版本。 –

相关问题