Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Dec 2000
    Location
    Palmyra, Virginia, USA
    Posts
    157
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Combining a folder full of files in PPT

    I posted the quest below in the PPT forum and it was suggested I cross post here. There does not seem to be a way to do it with PPTs own functions.

    I would like an automatic way to take an entire folder's worth of .ppt files and concatenate them end to end into one file. I want to end up with one big file. Doing it manually is slow and prone to error. Suggestions?

    Now, since the possibilities of doing it with VBA are more open, it would be nice to also somehow record the filename at the beginning of each concatenated file. I'm going to export it all as RTF so the pretty formats of the slides are not a concern, just the text.

    -----Paul-----

  2. #2
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Combining a folder full of files in PPT

    Hi Paul,

    The following code illustrates one way to do what you need.
    It uses the FileSearch object to locate all .ppt files in a given folder.
    Once you execute a FileSearch, .FoundFiles returns a sort of array that lets you get at each of the found files.
    Then for each found file, PowerPoint's InsertFile method is used - the ".FoundFiles(n)" part indicates the name of the file to be inserted, and the "ActivePresentation.Slides.Count" part tells it to insert the new slides, at the end of the presentation.

    Not sure about how to get the filename at the beginning of each concatenated file, though. ".FoundFiles(n)" does return the filename, but the tricky part is getting it into the beginning of the inserted file.
    Anyway:

    <pre>Sub InsertSlidesFromFiles()
    'Gary Frieder January 2001
    'Locate all ppt files in the indicated folder, and
    'insert their slide contents into the end of the current file.
    Dim objFS As FileSearch
    Dim n As Long
    Set objFS = Application.FileSearch
    With objFS
    .NewSearch
    .LookIn = "D:PPT_Temp"
    .FileType = msoFileTypePowerPointPresentations
    .Execute
    For n = 1 To .FoundFiles.Count
    ActivePresentation.Slides.InsertFromFile .FoundFiles(n), _
    ActivePresentation.Slides.Count
    Next n
    End With
    End Sub
    </pre>

    Regards,
    Gary

  3. #3
    2 Star Lounger
    Join Date
    Dec 2000
    Location
    Palmyra, Virginia, USA
    Posts
    157
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Combining a folder full of files in PPT

    Wow! Works great! Scared me a little when I triggered it and the computer went and stared at its navel for a while (should have tested on a smaller subset) but perfect results.

    Which makes me mildly embarrassed to ask for an upgrade but ... If I put a file named spacer.ppt in the folder immediately above the one being operated on, can you add a line that will insert that file at the end of each of the FoundFiles.(n)?

    And, what is the purpose of D:PPT_Temp? My D: drive is a ZIP, but what if it had been a CD or had not had a disk in it?

    Really, thank you for this help. It has solved a significant dilemma for me.

    -----Paul-----

  4. #4
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Combining a folder full of files in PPT

    Hi,

    Glad it worked - at least this way it's already been torture-tested.[img]/w3timages/icons/grin.gif[/img]

    The revised version below adds a line of code to add in "spacer.ppt" - you should be able to put the file in any folder you like, as long as you indicate the path in the code (i.e. replace "C:AnyOtherFolder".

    To avoid confusion, I've changed the drive letter reference to "C" - on my PC, the hard drive is partitioned so both C and D refer to the hard drive (and all the other drives get pushed up by one letter). So you can just replace "C:AnyFolder" with the actual path for the folder where you store the ppt files.

    I've also made a slight change to make it run a litle faster.

    <pre>Sub InsertSlidesFromFiles()
    'Gary Frieder January 2001
    'Locate all ppt files in the indicated folder, and
    'insert their slide contents into the end of the current file.
    'Revised to add a "spacer.ppt" file before each file inserted
    Dim objFS As FileSearch
    Dim n As Long
    Set objFS = Application.FileSearch
    With objFS
    .NewSearch
    .LookIn = "C:AnyFolder"
    .FileType = msoFileTypePowerPointPresentations
    .Execute
    For n = 1 To .FoundFiles.Count
    With ActivePresentation.Slides
    .InsertFromFile "C:AnyOtherFolderspacer.ppt", .Count
    .InsertFromFile objFS.FoundFiles(n), .Count
    End With
    Next n
    End With
    End Sub
    </pre>


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •