Consulting

Results 1 to 7 of 7

Thread: How to import mulitple files into one Power Point presentation.

  1. #1
    VBAX Regular
    Joined
    Sep 2013
    Posts
    7
    Location

    How to import mulitple files into one Power Point presentation.

    I'm using the following code to import all my single slide presentations into ONE presentation. (I have about 100 .pptx files in this directory) Since all the files have the same naming convention, is there a way to use a wild card to import ALL the *.pptx files?

    I've tried using ".....Overview July 2013 -Draft_*.pptx" and that will not work. Does anyone know how to accomplish this?

    Here is what I am using:


    Private Sub CommandButton1_Click()
    Dim FileName As String
    Dim Index, SlideStart, SlideEnd As Long
    ActivePresentation.Slides.InsertFromFile "C:\Documents and Settings\amta\Desktop\Unzipped\Overview July 2013 -DRAFT_0001.pptx", ActivePresentation.Slides.Count, 1
    ActivePresentation.Slides.InsertFromFile "C:\Documents and Settings\amta\Desktop\Unzipped\Overview July 2013 -DRAFT_0002.pptx", ActivePresentation.Slides.Count, 1
    ActivePresentation.Slides.InsertFromFile "C:\Documents and Settings\amta\Desktop\Unzipped\Overview July 2013 -DRAFT_0003.pptx", ActivePresentation.Slides.Count, 1
    End Sub

  2. #2
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    Maybe something like:

    Sub getfiles()
    Dim fso As Object
    Dim objfolder As Object
    Dim objfile As Object
    Dim opres As Presentation
    Dim strFind As String
    strpath = "C:\Documents and Settings\amta\Desktop\Unzipped\" 'Path to your folder must end in \
    strFind = "*Overview July 2013 -DRAFT*" ' * is wild card"
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set objfolder = fso.GetFolder(strpath)
    For Each objfile In objfolder.Files
    If objfile.Name Like strFind Then
    ActivePresentation.Slides.InsertFromFile objfile.Name, ActivePresentation.Slides.Count, 1
    End If
    Next objfile
    Set objsub = Nothing
    Set objfile = Nothing
    Set objfolder = Nothing
    Set opres = Nothing
    End Sub

    Just for the record

    Dim Index, SlideStart, SlideEnd As Long
    DOES NOT WORK IN VBA Only SlideEnd will be declared as Long the others as Variant

    Dim Index As Long, SlideStart As Long, SlideEnd As Long
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  3. #3
    VBAX Regular
    Joined
    Sep 2013
    Posts
    7
    Location
    Thanks, I updated my code, but it failed here:

    ActivePresentation.Slides.InsertFromFile objfile.Name, ActivePresentation.Slides.Count, 1

    Error Message said "slides (unknown member failed)". I'm not sure what to do from here.

  4. #4
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    Try:

    Sub getfiles()
    Dim fso As Object
    Dim objfolder As Object
    Dim objfile As Object
    Dim opres As Presentation
    Dim strPath As String
    Dim strFind As String
    strPath = "C:\Documents and Settings\amta\Desktop\Unzipped\" 'Path to your folder must end in \
    strFind = "*Overview July 2013 -DRAFT*" ' * is wild card"
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set objfolder = fso.GetFolder(strPath)
    For Each objfile In objfolder.Files
    If objfile.Name Like strFind Then
    ActivePresentation.Slides.InsertFromFile strPath & objfile.Name, ActivePresentation.Slides.Count, 1
    End If
    Next objfile
    Set objfile = Nothing
    Set objfolder = Nothing
    Set opres = Nothing
    End Sub
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  5. #5
    VBAX Regular
    Joined
    Sep 2013
    Posts
    7
    Location
    Worked like a charm!!! Thank you!!

    On a separate note, all the *.ppt files have the same background. However, when I imported the slides, it changed them all to a plain white background. Is there an easy way to add this to the code?

  6. #6
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    Easiest way is to start with a presentation having the same background set on the master
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  7. #7
    VBAX Regular
    Joined
    Sep 2013
    Posts
    7
    Location
    Thanks I realized that after I posted the question. All is working as expected! Thanks so much.

Posting Permissions

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