PDA

View Full Version : copying files in a folder and embedding it in powerpoint slide



itsme2216
03-15-2017, 10:11 AM
Hi,

In a folder there are some files which I want to copy and embed it in my powerpoint slide.
I have written a code, however it is giving error "Run Time Error . Shapes unknown member: Invalid Request on this line: Set obchart = pres.Shapes.AddOLEObject(100, 100, 200, 100, folderpath & fil.Name, True)

Sub copyfilestoppt()

Dim fso As Scripting.FileSystemObject
Dim fil As Scripting.File
Dim foldername As Scripting.Folder
Dim folderpath As String
Dim pres As PowerPoint.Slide
Dim obchart As Object


folderpath = "C:\Users\av\Desktop\Macro\Excel maacro"

Set fso = New Scripting.FileSystemObject

Set foldername = fso.GetFolder(folderpath)


Set pres = ActivePresentation.Slides(1)

'loop
For Each fil In foldername.Files

With ActivePresentation
Set pres = ActivePresentation.Slides(1)
Set obchart = pres.Shapes.AddOLEObject(100, 100, 200, 100, folderpath & fil.Name, True)

End With
Next fil

Set obchart = Nothing

End Sub