Consulting

Results 1 to 5 of 5

Thread: VBA to copy content from slide to slide master

  1. #1

    VBA to copy content from slide to slide master

    Hi,

    I am a teacher and head of department and part of my job is to write lesson plans in the form of powerpoints. I was hoping that someone might be able to help me with a bit of VBA wizardry to streamline the process slightly. Here is what I would like it to do in the order that I think it would work. The powerpoint document itself is attached.Lesson Powerpoint Template.pptx


    1. Copy the contents of the Good and Outstanding progress boxes to the clipboard.
    2. Go to the slide master
    3. Past the information to the slide master so it appears on all of the powerpoint slides.



    I'd be extremely grateful if anyone could help with this and thank you so much for taking the time to look.

    James

  2. #2
    VBAX Regular
    Joined
    Jan 2018
    Posts
    55
    Location
    Hi, James

    Try the code below and see if it works.

    Sub Macro1()
        Dim sld As Slide
        Dim shp As Shape
        Dim SourceTable As Table
        Dim Found As Boolean
        Dim GP As String
        Dim OP As String
    
    
        Found = False
        
        With ActivePresentation
            For Each sld In .Slides
                For Each shp In sld.Shapes
                    If shp.HasTable Then
                        If shp.Table.Cell(1, 1).Shape.TextFrame.TextRange.Text = "GOOD PROGRESS" _
                          And shp.Table.Cell(1, 2).Shape.TextFrame.TextRange.Text = "OUTSTANDING PROGRESS" Then
                            Set SourceTable = shp.Table
                            Found = True
                            Exit For
                        End If
                    End If
                Next shp
                If Found Then Exit For
            Next sld
        End With
        
        With SourceTable
            GP = .Cell(2, 1).Shape.TextFrame.TextRange.Text
            OP = .Cell(2, 2).Shape.TextFrame.TextRange.Text
        End With
        
        With ActivePresentation.SlideMaster
            For Each shp In .Shapes
                If shp.HasTable Then
                    shp.Table.Cell(2, 1).Shape.TextFrame.TextRange.Text = GP
                    shp.Table.Cell(2, 2).Shape.TextFrame.TextRange.Text = OP
                    Exit For
                End If
            Next shp
        End With
    End Sub

  3. #3
    This worked a treat, thank you so much!

    One more thing - I need a macro that will create 5 duplicates of the last slide in my powerpoint (so that there are 6 in total) then print off a sheet with 6 on one page, finally deleting the additional 5 slides once printed. If there's a simpler way of doing that then even better. Is that something that's doable?

    Thanks again for your help so far!

  4. #4
    VBAX Regular
    Joined
    Jan 2018
    Posts
    55
    Location
    You can do it without macro.

    In the print dialog box, just enter comma-separated slide numbers you want to print. For example, if the target slide number is 1, enter 1,1,1,1,1,1 in the textbox. And print as a 6-slide-per-page handout.
    Please see the attached image below.

    printDialogBox.jpg

  5. #5
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    If for some reason you want to use code to replicate yujin's idea (smart BTW) you could try

    Sub myPrint()
    Dim L As Long
    Dim lngCount As Long
    lngCount = ActivePresentation.Slides.Count
    With ActivePresentation.PrintOptions
    .Ranges.ClearAll
    For L = 1 To 6
    .Ranges.Add lngCount, lngCount
    Next L
    .OutputType = ppPrintOutputSixSlideHandouts
    .RangeType = ppPrintSlideRange
    End With
    ActivePresentation.PrintOut
    End Sub
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

Posting Permissions

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