VBA debug - run time error, unable to figure out how to fix it

Ellie1992

New Member
Joined
Aug 14, 2017
Messages
1
Hi,

I've created a macro which selects cells, sorts by one column high to low, then selects a range of cells, pastes in a different cell as a picture, names that picture, then opens powerpoint, selects a slide then, selects the named picture and pastes into position on the slide.

This is then repeated to fill content on 24 slides with upto 6 pictures pasted on each slide.

My understanding is that I've used select and activate too much and is therefore now bugging on the ActiveSheet.Pictures.Paste.Select part of the macro, the debug always highlights this bit of code but not always on the same sub, there are 24 subs.

I would be really grateful if anyone could help me on this.

Working from Excel 2016, windows operating system.

The VBA is as below - although I've only included one slide(sub) which repeated bugs out.


Code:
'############################### Slide 22 Digital #################################


Sub slide_22()




Sheets("Slide22").Select


'Sorting by percentage
'SOME_1
Range("BL2:BV34").Sort key1:=Range("BV2"), _
      order1:=xlDescending, Header:=xlYes
      
'sorting by combination formula


'SOME_2
Range("V2:AG25").Sort key1:=Range("AG2"), _
      order1:=xlDescending, Header:=xlYes
      
      
      
' Naming the boxes


Range("AK27:AM31").Select
    Selection.Copy
    Range("AK36").Select
    ActiveSheet.Pictures.Paste.Select
    Selection.ShapeRange.name = "SOME_2"
    
Range("CT2:CV7").Select
    Selection.Copy
    Range("CT10").Select
    ActiveSheet.Pictures.Paste.Select
    Selection.ShapeRange.name = "SOME_4"
    
    


    
''''''''' pasting it all


'first part: standard code, copy and paste


Dim PPApp As PowerPoint.Application
Dim PPPres As PowerPoint.Presentation
Dim iCht As Integer


Application.CutCopyMode = False


Set PPApp = GetObject(, "Powerpoint.Application")
Set PPPres = PPApp.ActivePresentation


' define spreadsheet


Sheets("Slide22").Select


' Paste the shapes individually


ActiveSheet.Shapes("SOME_1").Copy
With PPPres.Slides(22)
    .Shapes.Paste
    With .Shapes(.Shapes.Count)
        .Left = 0.05 * 28.34
        .Top = 3.43 * 28.34
    End With
End With
    
    
ActiveSheet.Shapes("SOME_2").Copy
With PPPres.Slides(22)
    .Shapes.Paste
    With .Shapes(.Shapes.Count)
        .Left = 0.85 * 28.34
        .Top = 10.45 * 28.34
    End With
End With




ActiveSheet.Shapes("SOME_4").Copy
With PPPres.Slides(22)
    .Shapes.Paste
    With .Shapes(.Shapes.Count)
        .Left = 16.29 * 28.34
        .Top = 10.85 * 28.34
    End With
End With
    
    
End Sub

Hope you guys can help,

Ellie
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

Forum statistics

Threads
1,224,819
Messages
6,181,153
Members
453,021
Latest member
Justyna P

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