0

I have never posted here before, so I thought I would give it a try. I have a macro that I have been using for over a year, and at beginning of the week it started to give me some problems. It will either just pull in the first slide of each powerpoint, or it will give me a Run-Time error "Slides (Unknown Member): Invalid request. Clipboard is empty or contains data which may not be pasted here."

The macro works fine if I just step through it using F8, the only time that I have issues is if I try to run it. It may be something super obvious, as I am pretty new to VBA. Thanks for the help!

Public Sub DoFiles()
Dim strFileName As String
Dim strFolderName As String
Dim objPresentation As Presentation
'set default directory here if needed
strFolderName = "Target Folder"
strFileName = Dir(strFolderName & "\*.ppt*")
Do While Len(strFileName) > 0
   Set objPresentation = Presentations.Open(strFolderName & "\" & 
strFileName)
On Error Resume Next

Dim i As Integer

For i = 1 To objPresentation.Slides.Count
objPresentation.Slides.Item(i).Copy
Presentations.Item(1).Slides.Paste
Presentations.Item(1).Slides.Item(Presentations.Item(1).Slides.Count).Design 
= _
    objPresentation.Slides.Item(i).Design
Next i
objPresentation.Close


    strFileName = Dir
Loop
End Sub
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343

1 Answers1

0

Did Steve's suggestion work?

Public Sub DoFiles()
    Dim strFileName As String
    Dim strFolderName As String
    strFolderName = "Target Folder"
    strFileName = Dir(strFolderName & "\*.ppt*")
    Do While Len(strFileName) > 0
        ActivePresentation.Slides.InsertFromFile strFolderName & "\" & strFileName, ActivePresentation.Slides.Count
        strFileName = Dir
    Loop
End Sub
TechnoDabbler
  • 1,245
  • 1
  • 6
  • 12