PowerPoint VBA - 代码在调试模式下工作,但无法在编译模式下运行

时间:2017-09-10 13:53:03

标签: vba powerpoint powerpoint-vba

Hello此代码在调试模式下运行,但无法在CommandBars.ExecuteMso的complie模式下运行 任何建议或帮助将不胜感激。

Sub CopyPasteAsUnion()

     Dim sld As Slide
     Dim shp As Shape

     Dim ShapeOne As String
     Dim ShapeTwo As String
     Dim oshpR As ShapeRange


     For Each sld In ActivePresentation.Slides
     ActiveWindow.View.GotoSlide sld.SlideIndex
          For Each shp In sld.Shapes
           If shp.HasTextFrame = True Then
                If shp.TextFrame.HasText = True Then
                      ShapeOne = shp.Name
                      ShapeTwo = shp.Name & "_1"
                      With shp.Duplicate
                         .Left = shp.Left
                         .Top = shp.Top
                         .Name = ShapeTwo
                      End With
                            Set oshpR = sld.Shapes.Range(Array(ShapeOne, ShapeTwo))
                            oshpR.Select
                            CommandBars.ExecuteMso ("ShapesUnion")
                    End If
                End If
         Next
     Next
End Sub

PowerPoint版I我正在使用:PowerPoint 2016(系统:Windows 7)。

编译时出错:

  

运行时错误' -2147467259(80004005)':方法' ExecuteMso'对象   ' _CommandBars'失败

0 个答案:

没有答案