I have been trying to write a macro that updates a presentation through powerpoint vba using tables from excel.
Here is what I am doing
- The code first deletes all pictures in the presentation,
- Then opens the excel workbook, copys a named range and pastes into the correct slide.
This exact code was working fine two days ago and is now saying the object is out of range for copying the range “PL”. Any help or tips would be great as this is my first time using powerpoint vba.
valnPath = "G:\valnpath\"
PriorPath = "G:\Priorpath\"
Dim xlApp As Object
Dim xlWorkBook As Object
Dim XL As Excel.Application
Dim PPSlide As PowerPoint.Slide
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
xlApp.DisplayAlerts = False
xlApp.AskToUpdateLinks = False
Set xlWorkBook = xlApp.Workbooks.Open(valnPath & "Presentation Tables 1208.xlsx", True, False)
Set XL = GetObject(, "Excel.Application")
XL.DisplayAlerts = False
XL.AskToUpdateLinks = False
XL.Range("PL").Copy
ActivePresentation.Slides(3).Select
Application.ActiveWindow.View.PasteSpecial DataType:=ppPasteEnhancedMetafile
Set XL = GetObject(, "Excel.Application")
XL.DisplayAlerts = False
XL.AskToUpdateLinks = False
XL.Range("AvE").Copy
ActivePresentation.Slides(5).Select
Application.ActiveWindow.View.PasteSpecial DataType:=ppPasteEnhancedMetafile
Set XL = GetObject(, "Excel.Application")
XL.Quit
Am I doing anything wrong?
Please help me with this,
Thank you
Try this: