将 Powerpoint Link 更改为不同的文件夹

Change Powerpoint Link to Different Folder

我想将 PowerPoint 演示文稿图表中的 link 转移到另一个文件夹。找到了一些代码,但它只选择要将 link 更改为的特定文件,而不是文件夹,我无法使用它,因为我的 PowerPoint 是 link 到两个不同的 Excel 文件(在同一文件夹中).

Sub M1()
Dim sld As Slide
Dim sh As Shape
Dim strNms As String
Dim intI As Integer
Dim strNewPath
Dim ExcelFile
Dim exl As Object
Set exl = CreateObject("Excel.Application")

'Open a dialog box to promt for the new source file.
ExcelFile = exl.Application.GetOpenFilename(, , "Select Excel File")
For Each sld In ActivePresentation.aSlides
    For Each sh In sld.Shapes
        If sh.Type = msoLinkedOLEObject Then
            With sh.LinkFormat
                strNms = .SourceFullName
                intI = InStr(1, strNms, "!")
                strNewPath = ExcelFile & Mid(strNms, intI, Len(strNms) - intI + 1)
                .SourceFullName = strNewPath
            End With
        End If
    Next sh
Next sld
End Sub

看看这里的代码:

Hyperlinks、OLE links、电影 links 和声音 links 的批量搜索和替换 http://www.pptfaq.com/FAQ00773_Batch_Search_and_Replace_for_Hyperlinks-_OLE_links-_movie_links_and_sound_links.htm

例如,它可以让您替换 linked 文件的路径(即不同的文件夹名称),但不会更改 linked 文件的名称。

重要提示:在 运行 代码之前,您必须将要重新link 的文件放在要重新link 的文件夹中。如果您将 link 更改为指向不存在的文件,PPT 只会对您微笑并说 "OK" 但它不会更改任何内容。