Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel powerpoint链接对象的新驱动器映射-VBA解决方案_Excel_Vba_Powerpoint - Fatal编程技术网

Excel powerpoint链接对象的新驱动器映射-VBA解决方案

Excel powerpoint链接对象的新驱动器映射-VBA解决方案,excel,vba,powerpoint,Excel,Vba,Powerpoint,powerpoint中的所有链接对象(链接到excel)将不再被识别,因为它已将服务器迁移到新路径并关闭了旧路径 我曾尝试使用()中的宏,但由于旧服务器不再运行,当宏尝试打开旧文件路径时,它会出错 有没有替代方案 你的代码还可以,我也测试过了 新链接的设置由应用程序处理: 如果设置链接图片的新SourceFullName(Shape.Type=msoLinkedPicture), 应用程序接受任何内容作为链接,代码不会引发任何错误 如果尝试为链接的OLE对象(Shape.Type=msoLi

powerpoint中的所有链接对象(链接到excel)将不再被识别,因为它已将服务器迁移到新路径并关闭了旧路径

我曾尝试使用()中的宏,但由于旧服务器不再运行,当宏尝试打开旧文件路径时,它会出错

有没有替代方案



你的代码还可以,我也测试过了

新链接的设置由应用程序处理:

  • 如果设置链接图片的新
    SourceFullName
    Shape.Type=msoLinkedPicture
    ),
    应用程序接受任何内容作为链接,代码不会引发任何错误
  • 如果尝试为链接的OLE对象(
    Shape.Type=msoLinkedOLEObject
    )设置新的
    SourceFullName
    ),则应用程序会立即测试新文件是否确实存在。
    如果链接的OLE对象不存在,则会出现错误

结果:您必须确保新路径指向现有文件(并且您需要对其具有适当的访问权限)。

您会遇到什么样的错误以及错误发生在哪里?做了一个快速测试,对我来说,代码正常,不会抛出错误运行时错误“-2147467259(80004005)”:LinkFormat(未知成员):失败。你能确认你的代码在到达文件时运行没有错误吗?我的回答有用吗?如果是,请按说明将其标记为答案。如果没有,请毫不犹豫地在下面发表评论。
Sub EditPowerPointLinks()

Dim oldFilePath As String
Dim newFilePath As String
Dim pptPresentation As Presentation
Dim pptSlide As Slide
Dim pptShape As Shape

'The old file path as a string (the text to be replaced)
oldFilePath = "String of\File Path\To Be Replaced\Excel File.xlsx"

'The new file path as a string (the text to replace with)
newFilePath = "String of\New File Path\Excel File 2.xlsx"

'Set the variable to the PowerPoint Presentation
Set pptPresentation = ActivePresentation

'Loop through each slide in the presentation
For Each pptSlide In pptPresentation.Slides

    'Loop through each shape in each slide
    For Each pptShape In pptSlide.Shapes

        'Find out if the shape is a linked object or a linked picture
        If pptShape.Type = msoLinkedPicture Or pptShape.Type _ 
        = msoLinkedOLEObject Then

            'Use Replace to change the oldFilePath to the newFilePath
            pptShape.LinkFormat.SourceFullName = Replace(LCase _
            (pptShape.LinkFormat.SourceFullName), LCase(oldFilePath), newFilePath)

        End If
    Next
Next

'Update the links
pptPresentation.UpdateLinks


End Sub