-
Dear Jon,
Thanks for helping me out. I really appreciate it.
I have tested the script of your latest reply and it does work. However, when the macro is ran, it gives me the following error: "Application-defined or object-defined error".
Sub PPT()
' instantiate powerpoint
Set pptApp = CreateObject("PowerPoint.Application")
Set pptPre = pptApp.Presentations.Add
' loop the sheets
For Each objSheet In ActiveWorkbook.Worksheets
If WorksheetFunction.Count(objSheet.UsedRange) > 0 Then
' Data in sheet so copy used range
objSheet.Range("RangeToCopy").CopyPicture Appearance:=xlScreen, Format:=xlPicture
Else
' No data in sheet, so copy chart
objSheet.ChartObjects(1).Chart.CopyPicture Appearance:=xlScreen, Size:=xlScreen, Format:=xlPicture
End If
'Create new slide for the data
Set pptSld = pptPre.Slides.Add(pptPre.Slides.Count + 1, ppLayoutBlank)
' paste the copied picture
pptSld.Shapes.Paste
Next
End Sub
The set ranges (scopes by Name Define) per sheet are all in the different slides in the PPT (as I wanted it to be), but for some reason it returns this error. VBA refers to the line which I made bold.
Yours sincerely,
Djani
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules