charlienguyen
New Member
- Joined
- Mar 5, 2020
- Messages
- 2
- Office Version
- 365
- Platform
- Windows
Hi VBA experts, I really need your helps regarding to the code I did recently.
In my code, I tried to copy picture of the data table and paste it to slide 5 of Powerpoint. There are about 20 worksheets like this so I combined all into 1 code (ran successfully), but all have same problem.
What I want is the copied picture is paste at where the text box with number 5 is in, but somehow when I copy it, the text box appears there (it happens to all other slides as well).
Does anyone know where I did wrongly? I really appreciate for the helps
In my code, I tried to copy picture of the data table and paste it to slide 5 of Powerpoint. There are about 20 worksheets like this so I combined all into 1 code (ran successfully), but all have same problem.
What I want is the copied picture is paste at where the text box with number 5 is in, but somehow when I copy it, the text box appears there (it happens to all other slides as well).
Does anyone know where I did wrongly? I really appreciate for the helps
VBA Code:
Sub Copy_Picture2()
Dim PPApp As PowerPoint.Application
Dim PPPres As PowerPoint.Presentation
Dim ActiveSlide As PowerPoint.Slide
Set PPApp = CreateObject("PowerPoint.Application")
PPApp.Visible = msoCTrue
PPApp.Presentations.Open Filename:="C:\Users\huhiuhi\Downloads\Telegram Desktop\Monthly report - final table picture.pptx"
Set PPPres = PPApp.ActivePresentation
Set ActiveSlide = PPPres.Slides(PPApp.ActiveWindow.Selection.SlideRange.SlideIndex)
Workbooks("Monthly report data.xlsm").Activate
ActiveWorkbook.Sheets("TCH - Slide 1").Range("B4:K18").CopyPicture
With PPPres.Slides(5)
.Select
.Shapes.Paste
.Shapes(1).Select
PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True
PPApp.ActiveWindow.Selection.ShapeRange.Left = 15.5
PPApp.ActiveWindow.Selection.ShapeRange.Top = 62.5
With ActiveSlide.Shapes(ActiveSlide.Shapes.Count)
.Width = 932
If .Width > 932 Then .Width = 932
End With
End With
End Sub