Okay, I've cleaned up the code. This is the entire module.
I have not tested it, but I've looked it over pretty carefully, with your reported errors in mind. I've tried to use consistent variable names; the problem with copy-paste programming is that different snippets use different variable names and may have other subtle differences. Copy-Paste programming isn't bad, necessarily, I do it all the time, but you have to be aware of the gotchas.
I assume only 1 or 2 named ranges on a sheet, or one chart if there are no named ranges.
Option Explicit
Sub PPT()
Dim iName As Long
Dim rName As Range
Dim nRange As Long
Dim dSlideCenter As Double
Dim pptApp As PowerPoint.Application
Dim pptPre As PowerPoint.Presentation
Dim pptSld As PowerPoint.Slide
Dim objSheet As Worksheet
Set pptApp = CreateObject("PowerPoint.Application")
Set pptPre = pptApp.Presentations.Add
' loop the sheets
For Each objSheet In ActiveWorkbook.Worksheets
'Create new slide for the data
Set pptSld = pptPre.Slides.Add(pptPre.Slides.Count + 1, ppLayoutBlank)
If WorksheetFunction.Count(objSheet.UsedRange) > 0 Then
' Data in sheet so copy used range(s)
For iName = 1 To 2
' initialize
Set rName = Nothing
nRange = 0
' look for named range
On Error Resume Next
Set rName = objSheet.Range("RangeToCopy" & CStr(iName))
On Error GoTo 0
If Not rName Is Nothing Then
' counter
nRange = nRange + 1
' copy range as picture
rName.CopyPicture Appearance:=xlScreen, Format:=xlPicture
' paste the copied picture
pptSld.Shapes.Paste
' Align pasted shape
pptApp.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
pptApp.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True
End If
Next
Else
' No data in sheet, so copy chart
objSheet.ChartObjects(1).Chart.CopyPicture Appearance:=xlScreen, Size:=xlScreen, Format:=xlPicture
' paste the copied picture
pptSld.Shapes.Paste
End If
' Align pasted shape
pptApp.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
pptApp.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True
If nRange = 2 Then
With ppSld.Shapes(ppSld.Shapes.Count - 1) ' first shape of two
dSlideCenter = .Left + .Width / 2
.Left = 1.5 * dSlideCenter - .Width / 2 ' center shape in left half of slide
End With
With ppSld.Shapes(ppSld.Shapes.Count) ' last shape of two
.Left = 1.5 * dSlideCenter + .Width / 2 ' center shape in right half of slide
End With
End If
Next
End Sub