PDA

View Full Version : amend excel VBA for powerpoint



siwelniffoc9
10-01-2015, 06:14 AM
I have the below code for excel which combines all open workbooks sheets into one workbook and closes the old copied workbook. i am wanting to adapt this so that it does the same in powerpoint, takes all open presentations and copies slides into active presentation. help please

Sub Macro1()
Dim wb As Workbook
Dim wbThis As Workbook
Set wbThis = ThisWorkbook
For Each wb In Application.Workbooks
If wb.Name = wbThis.Name Then GoTo 10
wb.ActiveSheet.Copy After:=wbThis.Sheets(Sheets.Count)
wb.Save
wb.Close
10
Next wb
End Sub

John Wilson
10-10-2015, 10:21 AM
Something like:



Sub combi()
Dim otarget As Presentation
Dim P As Long
Dim osource As Presentation
Set otarget = ActivePresentation
otarget.Windows(1).ViewType = ppViewNormal
otarget.Windows(1).Panes(2).Activate
For P = Presentations.Count To 1 Step -1
Set osource = Presentations(P)
If Not osource.Name = otarget.Name Then
osource.Windows(1).ViewType = ppViewNormal
osource.Windows(1).Panes(2).Activate
osource.Slides.Range.Copy
otarget.Slides.Paste (otarget.Slides.Count + 1)
DoEvents
osource.Close
End If
Next P
End Sub

Make sure the donor presentations have been saved.
If there are internal hyperlinks they will be broken because you will have duplicate Slide IDs