none
How to copy all shapes in a slide and paste into another? RRS feed

  • Question

  • What is the correct code to do the following:

    myobj.ActivePresentation.Slides(1).Shapes.copy

    myobj.Activepresentation.slides(2).shapes.paste

    Friday, September 12, 2014 1:19 PM

Answers

  • Hi Prabhakaran Karuppaih,

    To copy all shapes in a slide, we can select them first. Then we can use Selection.Copy and Shapes.Paste. And pleace active the slide which you want to copy the shapes copy from. Here is a sample for your reference:

    Sub copyShapes()
        
        ActivePresentation.Slides(1).Select
        ActivePresentation.Slides(1).Shapes.SelectAll
        Application.ActiveWindow.Selection.Copy
        ActivePresentation.Slides(2).Shapes.Paste
    
    End Sub

    Best regards

    Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Monday, September 15, 2014 3:28 AM
    Moderator
  • Hi Prabhakaran,

    >>How to explicitly refer a presentation or window by its name and copy its selection?<<
    Which version of PowerPoint are you using? As far as I know, we can active the window of presentation by following code:

    Application.Presentations("Presentation1").Windows(1).Activate


    And here is a sample copy the shapes from slide 1 of Presentation1 to slide 1 of Presentation2:

    Sub copyShapes()
    Application.Presentations("Presentation1").Windows(1).Activate
    Application.Presentations("Presentation1").Slides(1).Select
    Application.Presentations("Presentation1").Slides(1).Shapes.SelectAll
     
    Application.ActiveWindow.Selection.Copy
    Application.Presentations("Presentation2").Slides(1).Shapes.Paste
    
    End Sub

    And by default, one presentation is opened in one window. If the code doesn't work, would you mind sharing with us the scnario you are handling?

    Here is a helpful link for you learning developing PowerPoint solution:
    PowerPoint 2013 developer reference

    Best regards

    Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, September 17, 2014 5:42 AM
    Moderator

All replies

  • Hi Prabhakaran Karuppaih,

    To copy all shapes in a slide, we can select them first. Then we can use Selection.Copy and Shapes.Paste. And pleace active the slide which you want to copy the shapes copy from. Here is a sample for your reference:

    Sub copyShapes()
        
        ActivePresentation.Slides(1).Select
        ActivePresentation.Slides(1).Shapes.SelectAll
        Application.ActiveWindow.Selection.Copy
        ActivePresentation.Slides(2).Shapes.Paste
    
    End Sub

    Best regards

    Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Monday, September 15, 2014 3:28 AM
    Moderator
  • Thank you Fei.

    myobj.Windows(2).Selection.Copy  'Has to find a better way

    Because of not being able to refer the window or a presentation explicitly by its name. I have to write the following code...

     

    If myobj.Presentations.Count > 1 Then 'This code is required because of the Windows(2).selection.copy temp(0).SaveAs CurrentProject.Path & "\" & cell.value & ".pptx"

                temp(0).Close

    End If

    How to explicitly refer a presentation or window by its name and copy its selection?



    Tuesday, September 16, 2014 9:13 AM
  • Hi Prabhakaran,

    >>How to explicitly refer a presentation or window by its name and copy its selection?<<
    Which version of PowerPoint are you using? As far as I know, we can active the window of presentation by following code:

    Application.Presentations("Presentation1").Windows(1).Activate


    And here is a sample copy the shapes from slide 1 of Presentation1 to slide 1 of Presentation2:

    Sub copyShapes()
    Application.Presentations("Presentation1").Windows(1).Activate
    Application.Presentations("Presentation1").Slides(1).Select
    Application.Presentations("Presentation1").Slides(1).Shapes.SelectAll
     
    Application.ActiveWindow.Selection.Copy
    Application.Presentations("Presentation2").Slides(1).Shapes.Paste
    
    End Sub

    And by default, one presentation is opened in one window. If the code doesn't work, would you mind sharing with us the scnario you are handling?

    Here is a helpful link for you learning developing PowerPoint solution:
    PowerPoint 2013 developer reference

    Best regards

    Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, September 17, 2014 5:42 AM
    Moderator
  • Thanks Fei. Now I have made my code a bit shorter. Anyway. A Presentation can have multiple windows? I am not getting it (Sorry. I don't have much experience in making presentations earlier - its a bit tough to automate without knowing it)

    How come a presentation have a multiple windows? Can you please give me an example?

    Thanks in advance.

    Wednesday, September 17, 2014 6:58 AM
  • Hi Prahakaran,

    >>A Presentation can have multiple windows? How come a presentation have a multiple windows? Can you please give me an example?<<

    Yes, we can open a presentation in different window by clicking view tab->new window like figure below:

    If you have any other PowerPoint developing issue, please feel free to reopen a new thread in this forum.

    Best regards

    Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.



    Wednesday, September 17, 2014 8:02 AM
    Moderator