Excel 将Powerpoint链接更改为其他文件夹

Excel 将Powerpoint链接更改为其他文件夹,excel,powerpoint,vba,Excel,Powerpoint,Vba,我想将PowerPoint演示文稿图表中的链接转移到另一个文件夹。找到一些代码,但它只选择要更改链接的特定文件,而不是文件夹,我无法使用这些文件,因为我的PowerPoint链接到两个不同的Excel文件(在同一文件夹中) 请查看此处的代码: 批量搜索和替换超链接、OLE链接、电影链接和声音链接 例如,它允许您替换链接文件的路径(即不同的文件夹名称),但不更改链接文件的名称 重要提示:在运行代码之前,必须将要重新链接的文件放在要重新链接的文件夹中。如果你改变一个链接指向一个不存在的文件,PPT

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


请查看此处的代码:

批量搜索和替换超链接、OLE链接、电影链接和声音链接

例如,它允许您替换链接文件的路径(即不同的文件夹名称),但不更改链接文件的名称

重要提示:在运行代码之前,必须将要重新链接的文件放在要重新链接的文件夹中。如果你改变一个链接指向一个不存在的文件,PPT会对你微笑并说“好”,但它不会改变任何东西

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