VBA不会将范围复制到.ppt



我希望VBA将所有工作表粘贴到示例PPT中,该PPT从特定幻灯片开始,例如幻灯片NUM.3

但是,现在正在使用的代码,不要将所选区域粘贴到PPT文件中。你能帮我吗?

这是我的代码:

    For Each ws In ActiveWorkbook.Worksheets
        ws.Activate
        Set rng = ThisWorkbook.ActiveSheet.Range("A1:Z100")
'        Set mySlide = myPresentation.Slides.Add(myPresentation.Slides.Count + 1, 12)
'        SlideNumb = myPresentation.Slides.Count
        Set mySlide = myPresentation.Slides(SlideNumb).Select '(myPresentation.Slides.Count + 1, 12) '(myPresentation.Slides.Count + 1, 12)
        rng.Copy
        mySlide.Shapes.PasteSpecial DataType:=2  '2 = ppPasteEnhancedMetafile
        Set myShape = mySlide.Shapes(mySlide.Shapes.Count)
            myShape.LockAspectRatio = msoFalse
            myShape.Left = 36.72
            myShape.Top = 112.32
            myShape.Width = 854.64
            myShape.Height = 397.44
        Application.CutCopyMode = False
        ShtNum = ShtNum + 1
        SlideNumb = SlideNumb + 1
    Next ws

更改以下内容:

Set mySlide = myPresentation.Slides(SlideNumb).Select 

对此:

Set mySlide = myPresentation.Slides(SlideNumb) 

删除此项:

    Set myShape = mySlide.Shapes(mySlide.Shapes.Count)
        myShape.LockAspectRatio = msoFalse
        myShape.Left = 36.72
        myShape.Top = 112.32
        myShape.Width = 854.64
        myShape.Height = 397.44

删除评论,然后重试。

最新更新