首页 > 解决方案 > Powerpoint 更改链接

问题描述

Sub changelinkspp()
Dim oshp As Shape
Dim osld As Slide
Const replacethis As_String= _
"file:///C:\Users\admin\Desktop\file%20name%old\"

 Const replacewith As String = _
"file:///\\local\new%20folder\file%20name%new"

On Error Resume Next
For Each osld In ActivePresentation.Slides
For Each oshp In osld.Shapes

If oshp.LinkFormat.SourceFullName Like "*admin*" Then
    oshp.LinkFormat.SourceFullName = _
Replace(oshp.LinkFormat.SourceFullName, replacethis, replacewith)

这是主要问题发生的地方。这没用。似乎 vba 中的替换功能对 oshp.LinkFormat.SourceFullName 没有影响

    oshp.LinkFormat.Update
    End If
    Next oshp
    Next osld
    End Sub

{史蒂夫林兹伯格补充说:}试试这个作为测试:

Sub SimpleTest()

Dim oshp As Shape
Dim osld As Slide

' For test purposes:
Dim sSource As String
sSource = "file:///C:\Users\admin\Desktop\file%20name%old\"

Const replacethis As String = _
"file:///C:\Users\admin\Desktop\file%20name%old\"

Const replacewith As String = _
"file:///\\local\new%20folder\file%20name%new"

On Error Resume Next

If sSource Like "*admin*" Then
    Debug.Print Replace(sSource, replacethis, replacewith)
End If

End Sub

标签: vbahyperlinkpowerpoint

解决方案


推荐阅读