PDA

View Full Version : VBA to copy content from slide to slide master



jamesemaj89
01-07-2019, 05:07 PM
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.23530



Copy the contents of the Good and Outstanding progress boxes to the clipboard.
Go to the slide master
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

yujin
01-08-2019, 09:06 PM
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

jamesemaj89
01-21-2019, 04:57 PM
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!

yujin
01-21-2019, 08:39 PM
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.

23603

John Wilson
01-22-2019, 04:24 AM
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