Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-07-2016, 09:47 AM
Nick70 Nick70 is offline Copy slide then insert Text Windows 10 Copy slide then insert Text Office 2010 64bit
Novice
Copy slide then insert Text
 
Join Date: Jun 2016
Location: London
Posts: 13
Nick70 is on a distinguished road
Default Copy slide then insert Text

Hi,



I have some code that looks for a specific slide (ie.slide 2) in a Presentation (eg. PresentationA.pptx) then copies it into the active Presentation (eg. PresentationB.pptx) in a specific order (ie. in slide 12).

Code:
Sub Copy()
Dim objPres As Presentation
Dim i As Integer
Dim target As Presentation
Set target = ActivePresentation
src = Array(2)                                       ' source position
tgt = Array(12)                                      ' target position
Set objPres = Presentations.Open("C:\Users\PresentationA.pptx") 'target file
For i = LBound(src) To UBound(src)
    objPres.Slides(src(i)).Copy
    target.Slides.Paste tgt(i)
    target.Slides(tgt(i)).Design = target.Slides(src(i)).Design
Next i
objPres.Close
End Sub
I would now like to insert some text in slide which has been copied so that when I look at PresentationB.pptx I can recognize it easily.

I was thinking of inserting a text saying "NEW" in bold red.

How can I amend my code so that once the slide is copied into PresentationB.pptx it will also have such text saying "NEW"?

Thanks,
Nic
Reply With Quote
  #2  
Old 06-07-2016, 10:05 AM
JohnWilson JohnWilson is offline Copy slide then insert Text Windows 7 64bit Copy slide then insert Text Office 2010 32bit
Programmer
 
Join Date: Nov 2008
Location: UK
Posts: 1,912
JohnWilson has a spectacular aura aboutJohnWilson has a spectacular aura about
Default

It's not clear why you specified an Array but maybe there is code you are not showing.

If it's just slide 2 being inserted at 12 try this (not tested)

Code:
Sub Copy()
Dim newslide As SlideRange
Dim pasteFrom As Long
Dim pasteTo As Long
Dim objPres As Presentation
Dim i As Integer
Dim target As Presentation
Set target = ActivePresentation
pasteFrom = 2                                 ' source position
pasteTo = 12                              ' target position
'Note I changed the Path
Set objPres = Presentations.Open("C:\PresentationA.pptx") 'target file

    objPres.Slides(pasteFrom).Copy
   Set newslide = target.Slides.Paste(pasteTo)
   With newslide(1).Shapes.AddShape(msoShapeRectangle, 10, 10, 100, 20)
   .Fill.Visible = False
   .TextFrame.TextRange = "NEW"
   .TextFrame.TextRange.Font.Color.RGB = vbRed
   End With
    target.Slides(pasteTo).Design = target.Slides(pasteFrom).Design

objPres.Close
End Sub
__________________
Microsoft PowerPoint MVP 2007-2023
Free Advanced PowerPoint Tips and Tutorials
Reply With Quote
  #3  
Old 06-07-2016, 10:14 AM
Nick70 Nick70 is offline Copy slide then insert Text Windows 10 Copy slide then insert Text Office 2010 64bit
Novice
Copy slide then insert Text
 
Join Date: Jun 2016
Location: London
Posts: 13
Nick70 is on a distinguished road
Default

Great thanks I will try this code.

Reason for the array is that I have to copy more than 1 slide (so the array) I put 1 to make simplify things.

Thanks,
Nic
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy slide then insert Text Insert 4/3 presentation on 16/9 slide judithvg PowerPoint 3 09-04-2015 12:02 AM
Copy slide then insert Text Need macro to copy object on slide 4 to current slide djlee PowerPoint 2 02-11-2015 10:37 AM
Copy slide then insert Text Lyric slide show - using a variable to pull text from next slide elfman12 PowerPoint 3 03-08-2013 12:27 AM
Copy slide then insert Text Text typed on slide x ports to slide y automatically? Thinker PowerPoint 5 07-26-2012 11:59 PM
Copy slide then insert Text slide image wont copy with text to new slide lewis.mulhollen PowerPoint 1 12-17-2011 03:17 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:17 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft