Pasting power point slide using "source format (K")

haplc

Board Regular
Joined
May 27, 2004
Messages
71
Dear All,

I am using VBA to copy slide from one presentation and paste it to other presentation. Idea is to copy slide which contains value entered by the user (like country name etc). I am able to copy and paste - however, could paste using source format of the source presentation. So can any body help me to find out how to paste slide from one presentation and paste into other power point presentation using "keep source format (K)" option.

Here is the code I am using:
Dim NRow As Long ' number of slides
Dim VSNo As Long ' number of last slide
Dim VPName As String ' name of PLC name keyed-in in user form
Dim VAname As String ' name of Application name keyed-in in user form
Dim VBusName As String ' name of BUS name keyed-in in user form

VSNo = UserForm1.SNo.Value ' getting number of last slide from user form
VPName = UserForm1.PName.Value ' getting PLC name from user form
VCName = UserForm1.CName.Value ' getting Country name from user form
VAname = UserForm1.AName.Value ' getting application from user form
VBusName = UserForm1.BusName ' getting BUs name from user form

Dim pres1 As PowerPoint.Presentation, pres2 As PowerPoint.Presentation, pp As Object 'defeining two power point: Press 1: source, Press 2: destination

' here creating a new presentation which will be destination presentation
PowerPoint.Application.Presentations.Add.SaveAs "Countries.pptm", ppSaveAsDefault
ActivePresentation.Slides.Add Index:=ActivePresentation.Slides.Count + 1, Layout:=ppLayoutCustom

'checking all slides
For NRow = 1 To VSNo
On Error Resume Next

Set pp = GetObject(, "PowerPoint.Application")
If Err.Number <> 0 Then Set pp = CreateObject("PowerPoint.Application")
On Error GoTo 0

Set pres1 = PowerPoint.Application.Presentations("SelPPT - destinationF.pptm") ' this is source file
Set pres2 = PowerPoint.Application.Presentations("Countries.pptm") ' destination file
'ActivePresentation.Slides.Add Index:=ActivePresentation.Slides.Count + 1, Layout:=ppCustomLayout

' if source file contains a text , for example , country name, then
If PowerPoint.Application.Presentations("SelPPT - destinationF.pptm").Slides(NRow).Shapes(12).TextFrame.TextRange.Text Like "" & VCName & "" Then

'copy the slide that contains the name of country given in user form
pres1.Slides(NRow).Copy
'pasting the slide that contains the name of country given in user form in destination file
pres2.Slides.Paste pres2.Slides.Count + 1

End If

Next
pres2.Slides(1).Delete
pres2.Save
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

Forum statistics

Threads
1,215,561
Messages
6,125,542
Members
449,236
Latest member
Afua

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top