Slide number indicator

charlienguyen

New Member
Joined
Mar 5, 2020
Messages
2
Office Version
  1. 365
Platform
  1. 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
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
question.png
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
@charlienguyen
If your only issue is seeing the 5 textbox, rather than having covereed it with the picture then you have to be aware that elements of the picture will be transparent.
Assuming that the 5 textbox is shape 1 then you can hide it with eg
VBA Code:
.Shapes(1).Visible = False

Otherwise, can you perhaps clarify how you want this picture to position relative to the 5 textbox?
I'm also confused by the centre/ middle aligning, before positioning with left and top, of shape (1), which is surely not the picture?
 
Upvote 0

Forum statistics

Threads
1,214,907
Messages
6,122,185
Members
449,071
Latest member
cdnMech

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top