用vba脚本获得ppt内嵌视频地址(thinkvd开发日志)

本文提供了一个VBA脚本,用于编辑PPT中形状的链接,特别是内嵌视频的链接。用户需先选择一个包含视频的形状,然后脚本会获取并允许编辑其链接地址。如果链接有效,脚本将更新链接;否则,将显示错误消息。C++程序实现类似功能时需考虑shape的类型。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

载自: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类型即可.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值