首页 文章

PowerPoint VBA打破OLEFormat对象中的链接

提问于
浏览
0

我有一个带有两个嵌入式excel对象的PowerPoint 2007幻灯片 . 我想访问sheet1选项卡并中断所有链接 . 我试图按值复制和粘贴,但我被卡住了,虽然代码运行,但它什么也没做 . 任何帮助是极大的赞赏 .

Dim oSl As Slide Dim oSheet As Object Dim PPApp As PowerPoint.Application Dim PPPres As PowerPoint.Presentation

对于每个oSl在ActivePresentation.Slides为每个oSh在oSl.Shapes

ActiveWindow.View.GotoSlide oSl.SlideIndex
    If oSh.Type = msoEmbeddedOLEObject Then
          oSh.OLEFormat.Activate
              With oSh.OLEFormat.Object

            .Application.Workbooks(1).Worksheets(1).Cells.Copy
           .Application.Workbooks(1).Worksheets(1).Cells.PasteSpecial Paste:=xlPasteValues


             End With


        ActiveWindow.Selection.Unselect
        ActiveWindow.View.GotoSlide oSl.SlideIndex

    End If

Next

下一个结束子

1 回答

  • 1

    更新/编辑...跳过应用程序更新行,尝试改为:

    If oSh.Type = msoEmbeddedOLEObject Then
        With oSh.OLEFormat.Object   ' added .Object here
            .Activate
            .Application.workbooks(1).worksheets(2).Cells.Copy
            .Application.workbooks(1).worksheets(2).Cells.PasteSpecial Paste:=xlPasteValues
        End With
    End if
    

    首先,在上面的代码中定义一个常量lxPasteValues As Long = -4163或将xlPasteValues替换为-4163 .

相关问题