用vba腳本獲得ppt內嵌視頻地址(thinkvd開發日誌)

載自:http://www.pptfaq.com/FAQ00433.htm
Sub EditLink()
' Edit links of some types
' Little error checking.  It works or not.  No harm if not.
    Dim sLinkSource As String
    Dim sOriginalLinkSource As String
    If ActiveWindow.Selection.ShapeRange.Count <> 1 Then
      MsgBox ("Please select one and only one shape, then try again.")
      Exit Sub
    End If
    With ActiveWindow.Selection.ShapeRange(1)
        'MsgBox .LinkFormat.SourceFullName
        sOriginalLinkSource = .LinkFormat.SourceFullName
        sLinkSource = InputBox("Edit the link", "Link Editor", sOriginalLinkSource)
        If sLinkSource = sOriginalLinkSource Then
            ' nothing changed; our work on this planet is done
            Exit Sub
        End If
        If sLinkSource = "" Then
            ' The user canceled; quit:
            Exit Sub
        End If
        ' Get the filename portion of the link in case it's a link to a range
        Debug.Print Mid$(sLinkSource, 1, InStr(sLinkSource, ".") + 3)
        ' Is it a valid filename?  Is the file where it belongs?
        ' Test against the filename portion of the link in case the link includes
        ' range information
        If Dir$(Mid$(sLinkSource, 1, InStr(sLinkSource, ".") + 3)) <> "" Then
            .LinkFormat.SourceFullName = sLinkSource
            .LinkFormat.Update
        Else
            MsgBox "Can't find " & sLinkSource
        End If
    End With
End Sub

鏈接網頁裏面有使用說明,在此不多說了。
注意:一定要選擇一個帶視頻的且激活的shape, 否則vba腳本得不到.LinkFormat.SourceFullName
同功能的C++程序略與它有點差異,需要判斷shape.type類型即可.
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章