I want VBA to paste all the Worksheets into example PPT, which started from particular slide, for example slide NUM.3
However the code which is in use right now, do not paste the selected area into PPT file. Could you help me?
Here is my code:
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
Change this:
Set mySlide = myPresentation.Slides(SlideNumb).Select
To this:
Set mySlide = myPresentation.Slides(SlideNumb)
Delete this:
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
remove the comments and give it a try again.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.