Results 1 to 8 of 8
  1. #1
    JrMontgom is offline Competent Performer
    Windows Vista Access 2010 32bit
    Join Date
    Sep 2012
    Location
    Vero Beach, FL USA
    Posts
    124

    Automate using VBA Copy/paste of Powerpoint slide


    I have ,what I call, a PowerPoint template (PP Template)with slides that are place holders that change weekly. I want to copy a series of slides from a NEW presentation to the PP Template. For example someone sends me a set of slides to be "pasted" into the PP template at a slide position #15 (variable). I then want to save the PP template as a new presentation (Save as) with these additional slides pasted at slide position#15-to end. I can open the PP template and display it on an unbound object frame and iterate through the slides using first/next/previous/last command buttons but I can find out how to copy a range of slides from 1 PP presentation to another.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    You want VBA behind a PP file? This is an Access forum. Maybe a PP forum would be more helpful.

    Review http://msdn.microsoft.com/en-us/libr.../ee814734.aspx

    Google: Access vba copy slides from another powerpoint file
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    JrMontgom is offline Competent Performer
    Windows Vista Access 2010 32bit
    Join Date
    Sep 2012
    Location
    Vero Beach, FL USA
    Posts
    124

    MSAccess Automate Powerpoint creation from DB and PP template

    Quote Originally Posted by JrMontgom View Post
    I have ,what I call, a PowerPoint template (PP Template)with slides that are place holders that change weekly. I want to copy a series of slides from a NEW presentation to the PP Template. For example someone sends me a set of slides to be "pasted" into the PP template at a slide position #15 (variable). I then want to save the PP template as a new presentation (Save as) with these additional slides pasted at slide position#15-to end. I can open the PP template and display it on an unbound object frame and iterate through the slides using first/next/previous/last command buttons but I can find out how to copy a range of slides from 1 PP presentation to another.
    The process is a MSAccess app automating the PP process described above. I can do this mechanically in PP but I want to automate the process in MSAccess Run time.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931

    PowerPoint

    Probably need code to open the two PP files. I have only done that with Excel files but I expect would be much the same. Select VBA reference: Microsoft PowerPoint 12.0 Object Library

    This works:
    Sub PP()
    Dim oPP As PowerPoint.Application
    Dim oPP1 As PowerPoint.Presentation
    Dim oPP2 As PowerPoint.Presentation
    Set oPP = New PowerPoint.Application
    oPP.Activate
    Set oPP1 = oPP.Presentations.Open("C:\Temp\Test1.ppt")
    Set oPP2 = oPP.Presentations.Open("C:\Temp\Test2.ppt")
    oPP1.Slides(1).Copy
    oPP2.Windows(1).Activate
    oPP2.Slides.Paste
    End Sub

    Review
    http://msdn.microsoft.com/en-us/libr...ffice.11).aspx
    http://support.microsoft.com/kb/161661

    I simply cannot find any more sample code for Access to interact with PowerPoint. Now you are on your own.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Dunro is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2011
    Location
    Toronto, Canada
    Posts
    39
    What's in the Access database itself? file names? slide positions?

    If there's no Access database already and you're just looking to automate compiling a Powerpoint from multiple sources every week, there are better ways to approach the problem.

  6. #6
    JrMontgom is offline Competent Performer
    Windows Vista Access 2010 32bit
    Join Date
    Sep 2012
    Location
    Vero Beach, FL USA
    Posts
    124

    Solution found for Copy/Paste PP slides

    Quote Originally Posted by June7 View Post
    Probably need code to open the two PP files. I have only done that with Excel files but I expect would be much the same. Select VBA reference: Microsoft PowerPoint 12.0 Object Library

    This works:
    Sub PP()
    Dim oPP As PowerPoint.Application
    Dim oPP1 As PowerPoint.Presentation
    Dim oPP2 As PowerPoint.Presentation
    Set oPP = New PowerPoint.Application
    oPP.Activate
    Set oPP1 = oPP.Presentations.Open("C:\Temp\Test1.ppt")
    Set oPP2 = oPP.Presentations.Open("C:\Temp\Test2.ppt")
    oPP1.Slides(1).Copy
    oPP2.Windows(1).Activate
    oPP2.Slides.Paste
    End Sub

    Review
    http://msdn.microsoft.com/en-us/libr...ffice.11).aspx
    http://support.microsoft.com/kb/161661

    I simply cannot find any more sample code for Access to interact with PowerPoint. Now you are on your own.

    Code:
    Dim bResult As Boolean
    'Dim pptObj As PowerPoint.Application
    Dim strCopyname As String
    
    
    On Error GoTo ErrorHandler
    Const CALLER As String = " Form_frmOOSTemplate:MakePPT "
     ' Open PowerPoint
        
        bResult = True
        Set mPPTobj = New Powerpoint.Application
      mPPTobj.Visible = True
       mPPTobj.WindowState = ppWindowMinimized
        'default  file names #1 Source fILE
        
        If (IsNull(strPowerPointFile1) Or strPowerPointFile1 = vbNullString) Then
                #If conbTest Then
                    strPowerPointFile1 = mstrTestOOSAV & "PP Service Template.ppt"
                #Else
                    strPowerPointFile1 = mstrHymnbank & "PP Service Template.ppt"
                #End If
                
        End If
           '#2 Destination file either test r normal environment
        If (IsNull(strPowerPointFile2) Or strPowerPointFile2 = vbNullString) Then
                #If conbTest Then
                    'testdir
                    strPowerPointFile2 = mstrTestOOSAV & "App2.pptx"
                #Else
                    strPowerPointFile2 = mstrHymnbank & "App2.pptx"
                #End If
        
        End If
        
        
        
        ' Fill a collection with all Slide IDs. after opening the PP slide show
        With mPPTobj.Presentations.Open(strPowerPointFile1)
            Set mcolSlideIDs1 = New Collection
            'Dim mppSlide As PowerPoint.Slide
            
            
            'MsgBox (mPPTobj.Presentations.Item(strPowerPointFile).Slides.Item(1).SlideNumber)
            For Each mppSlide In .Slides
                mcolSlideIDs1.Add mppSlide.SlideID
                'Copy??
               ' ppSlide.Copy
               strCopyname = mppSlide.Name
                Debug.Print strCopyname
                '.Slides.Item (strCopyname)
            
             Next
           ' .Close
        End With
        
      ' Specify OLE Class, Type, SourceDoc, SourceItem and other properties.
       With pptFrame
            .Class = "Microsoft Powerpoint Slide"
           .OLETypeAllowed = acOLELinked
            .SourceDoc = strPowerPointFile1
        End With
    End Sub
    Thanks for the "jump start". I have left out the code to enable the command btns for first/next/previous\Last slides to view on PP1. This works now I have to figure out why I have multiple PP presentations for PP1 and PP2 displayed.

    Her is the code for COpy/paste

    Code:
    Dim intSlideNum As Integer
    
    
    'mstrApp1 = mstrDropBox & mstrTestPath & "App1.pptx"
    mstrApp1 = mstrDropBox & "John M Slides\" & "PP Service TEMPLATE.PPT"
    mstrApp2 = mstrDropBox & mstrTestPath & "App2.pptx"
    
    
    If IsFile(mstrApp1) And IsFile(mstrApp2) Then
        'copy from 1 paste to 2
        'first get #1 App's slideNum
        intSlideNum = mlngSlideIndex1
        If CopyPasteSlide(mstrApp1, mstrApp2, intSlideNum, 1) Then
            'MsgBox ("Success")
            UpdateChkBox (True)
        Else
            MsgBox ("failed")
            UpdateChkBox (False)
        End If
    Else
        MsgBox ("Enter correct file names" & vbNewLine & mstrApp1 & vbNewLine & mstrApp2)
        UpdateChkBox (False)
        
    End If
    Here is code for Copy\Paste any slide as selected by user from a specified directory

    Code:
     If BrowseHymnFiles(strDirname, strHymn) Then
                MsgBox ("Hymn = " & FileNameFromPath(strHymn))
                mstrAppTmp = mstrApp1   'mstrDropBox & "John M Slides\PP Service Template.ppt"
    
                
                mstrApp1 = strHymn     'mstrDropBox & "John M Slides\PP Service Template.ppt"
                mstrApp2 = mstrDropBox & mstrTestPath & "App2.pptx"  'strDirName & FileNameFromPath(strHymn)   'chg 9/29/2012
               'dup mstrAppTmp = mstrDropBox & "John M Slides\PP Service Template.ppt"  'Temp spot
                'set the presentation #1 to the Hymn not to template pptx
                If Not moPP1 Is Nothing Then
                    Set moPP1 = Nothing
                End If
                
                If IsFile(mstrApp1) And IsFile(mstrApp2) Then
                    If CopyPasteSlide(mstrApp1, mstrApp2, intSlideNum, 2) Then
                        'MsgBox ("Success")
                         UpdateChkBox (True)
                        'reset app names & object back
                        mstrApp1 = mstrAppTmp
                        'recreate presentation
                        
                        If Not moPP1 Is Nothing Then
                            moPP1.Close  'chg 10/1/2012 added close of Hymn presentation
                            Set moPP1 = Nothing
                            Set moPP1 = mPPTobj.Presentations.Open(mstrApp1)
                        Else
                            Set moPP1 = mPPTobj.Presentations.Open(mstrApp1)
                        End If
                    Else
                        MsgBox ("failed")
                         UpdateChkBox (False)
                    End If
                Else
                    MsgBox ("Enter correct file names" & vbNewLine & mstrApp1 & vbNewLine & mstrApp2)
                     UpdateChkBox (False)
                End If
            
            Else
            
            End If

  7. #7
    johnwatkins35 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Posts
    5
    Dunro,
    You said there was an easier way to

    "What's in the Access database itself? file names? slide positions? If there's no Access database already and you're just looking to automate compiling a Powerpoint from multiple sources every week, there are better ways to approach the problem."

    well what are the better ways because i'm been searching the internet these forums and other forums for this solution. Can you guide me in the right direction?

  8. #8
    johnwatkins35 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Posts
    5
    JrMontgom,
    What is this template your talking about?

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Copy and Paste Row (vb)
    By Computer202 in forum Programming
    Replies: 7
    Last Post: 03-28-2014, 01:59 AM
  2. Copy-Paste on Internet
    By BorisGomel in forum Access
    Replies: 5
    Last Post: 11-09-2011, 10:33 AM
  3. Copy-Paste
    By BorisGomel in forum Access
    Replies: 4
    Last Post: 10-25-2011, 07:17 AM
  4. Copy / Paste some fields
    By isnpms in forum Access
    Replies: 2
    Last Post: 08-25-2010, 10:13 AM
  5. Replies: 2
    Last Post: 12-03-2009, 08:08 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums