0

我有一个 PowerPoint 演示文稿,其中包含 Excel 表格作为对象。

Excel 文件每周更新一次。更新 Excel 文件后,我打开 PowerPoint,双击每个对象 -> 菜单数据 -> 编辑链接 -> 选择所有源 -> 更新值。

宏是否可以在 PowerPoint 中找到 Excel 对象并更新它们?

在网上搜索后,我设法获得了以下代码,这使我进入了双击对象的步骤,但我不知道如何更新链接。

Sub update_objects()

    Dim it As String
    Dim i As Integer
    For i = 1 To ActiveWindow.Selection.SlideRange.Shapes.Count
        With ActiveWindow.Selection.SlideRange.Shapes(i)
            If .Type = msoEmbeddedOLEObject Then
                ActiveWindow.Selection.SlideRange.Shapes(i).Select.OLEFormat.DoVerb
            End If
        End With
    Next i
End Sub
4

1 回答 1

0

此代码有效,但并非在所有情况下都有效。它是为 2010 年编写的。根据需要更改类型。7 是 Excel 嵌入对象。

Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    Sub open_and_close_all_objects()
    'This will open and then close all charts and graphs in the presentation to allow them to keep the data
    'Why this is needed is a question to be answered in the future.


    Dim oSH As Shape
    Dim oSl As Slide
    Dim oSheet As Object


    For Each oSl In ActivePresentation.Slides
        For Each oSH In oSl.Shapes

        ActiveWindow.View.GotoSlide oSl.Slideindex
             If oSH.Type = 7 Then
                oSH.Select
                oSH.OLEFormat.Activate

                Call Sleep(1500)

                ActiveWindow.Selection.Unselect
                ActiveWindow.View.GotoSlide oSl.Slideindex
            End If

        Next


     Next
     End Sub
于 2016-12-07T19:10:36.983 回答