gpt4 book ai didi

VBA 不将范围复制到 .ppt

转载 作者:行者123 更新时间:2023-12-04 20:33:05 26 4
gpt4 key购买 nike

我希望 VBA 将所有工作表粘贴到示例 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

删除评论并再试一次。

关于VBA 不将范围复制到 .ppt,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46929170/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com