+ Reply to Thread
Results 1 to 11 of 11

Copy ranges from multiple worksheets in excel and then paste special in Powerpoint

  1. #1
    Registered User
    Join Date
    03-15-2013
    Location
    Toronto Canada
    MS-Off Ver
    Excel 2003
    Posts
    7

    Smile Copy ranges from multiple worksheets in excel and then paste special in Powerpoint

    hi, hopefully someone can help me.... Im new to vba and have found some macros that will open powerpoint from excel and others that will copy and paste from excel to powerpoint, but Id like to be able to open Powerpoint template from Excel, copy worksheet data range A1 to say M20, and then paste special into the new powerpoint. Since I have about 50 work sheets with separate data ranges, id like it to cycle to pick up sequentially each sheet and paste in PPoint on a new slide.....

    Is this even possible?

    i've tried this link but I get errors when using it.

    http://vbaexpress.com/kb/getarticle.php?kb_id=370

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Copy ranges from multiple worksheets in excel and then paste special in Powerpoint

    Hi MClarke,

    It should be possible - can you post your code??
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Registered User
    Join Date
    03-15-2013
    Location
    Toronto Canada
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Copy ranges from multiple worksheets in excel and then paste special in Powerpoint

    Hi, sorry for my late response! Here is what I have so far, but i get an error at the Copy Range line where it says " sub or Function Not Defined" .... I'm guessing its my syntax thats incorrect. Here is the code-

    Sub ExcelToNewPowerPoint()
    Dim PPApp As PowerPoint.Application
    Dim PPPres As PowerPoint.Presentation
    Dim PPSlide As PowerPoint.Slide

    ' Create instance of PowerPoint
    Set PPApp = CreateObject("Powerpoint.Application")

    ' For automation to work, PowerPoint must be visible
    ' (alternatively, other extraordinary measures must be taken)
    PPApp.Visible = True

    ' Create a presentation
    Set PPPres = PPApp.Presentations.Add

    ' Some PowerPoint actions work best in normal slide view
    PPApp.ActiveWindow.ViewType = ppViewSlide

    ' Add first slide to presentation
    Set PPSlide = PPPres.Slides.Add(1, ppLayoutTitleOnly)


    Dim i As Integer

    For i = 1 To ThisWorkbook.Sheets.Count

    Sheets(i).Activate

    Copy xlRange
    xlValue = relative
    '
    ActiveCell.Range("A1:P35").Select
    Selection.Copy

    GoTo ppt
    Selection = ppt
    Paste special
    Insert New Slide
    GoTo msoslide

    GoTo Excel
    Next i


    End

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Copy ranges from multiple worksheets in excel and then paste special in Powerpoint

    Hi MClarke,

    If xlRange is defined somewhere then the syntax would be:

    Please Login or Register  to view this content.
    Should much of your code be comments or is msoslide a procedure name??

    I don't have enough information to render substantive advice
    Last edited by xladept; 03-20-2013 at 03:08 PM.

  5. #5
    Registered User
    Join Date
    03-15-2013
    Location
    Toronto Canada
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Copy ranges from multiple worksheets in excel and then paste special in Powerpoint

    Hi,

    So here is what I have. It works so far in that it opens PowerPoint and then pastes the desired range. The issue is it then stops at Worksheet Tab 12, and I get an error. It also pastes it in the far left hadn corner of the slide, but thats just a positioning format issue. If you know how to fix the cycle it would be great!


    Sub ExcelToNewPowerPoint()

    Dim PPApp As PowerPoint.Application
    Dim PPPres As PowerPoint.Presentation
    Dim PPSlide As PowerPoint.Slide

    ' Create instance of PowerPoint
    Set PPApp = CreateObject("Powerpoint.Application")

    ' For automation to work, PowerPoint must be visible
    ' (alternatively, other extraordinary measures must be taken)
    PPApp.Visible = True

    ' Create a presentation
    Set PPPres = PPApp.Presentations.Add

    ' Some PowerPoint actions work best in normal slide view
    PPApp.ActiveWindow.ViewType = ppViewSlide

    ' Add first slide to presentation
    Set PPSlide = PPPres.Slides.Add(1, ppLayoutBlank)

    'GoTo Excel


    Dim i As Integer

    For i = 1 To ThisWorkbook.Sheets.Count

    Sheets(i).Activate


    '
    Range("A1:P35").Select
    'Selection.Copy
    Selection.CopyPicture Appearance:=xlScreen, _
    Format:=xlPicture


    'ActivePresentation.Slides(i).Select
    PPApp.Activate
    PPApp.ActivePresentation.Slides(i).Shapes.PasteSpecial ppPasteEnhancedMetafile
    'PPApp.ActivePresentation.Slides(i).Shapes.Paste


    ' GoTo Excel
    Set PPSlide = PPPres.Slides.Add(i + 1, ppLayoutBlank)
    Next i

    PPApp.Activate

    End Sub

  6. #6
    Registered User
    Join Date
    03-15-2013
    Location
    Toronto Canada
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Copy ranges from multiple worksheets in excel and then paste special in Powerpoint

    Oppsies my apologies. It seems to run fine, but I do get an error at

    Selection.CopyPicture Appearance:=xlScreen, _
    Format:=xlPicture

    Once pressing play again on the macro it runs the operation fine. Not sure why it hangs there though.

  7. #7
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Copy ranges from multiple worksheets in excel and then paste special in Powerpoint

    Hi,

    Maybe:
    Please Login or Register  to view this content.
    or since those are the default values:
    Please Login or Register  to view this content.
    Last edited by xladept; 03-21-2013 at 12:51 PM.

  8. #8
    Registered User
    Join Date
    03-15-2013
    Location
    Toronto Canada
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Copy ranges from multiple worksheets in excel and then paste special in Powerpoint

    Awesome thank you! That does stop it from hanging.

    I have a another question....if you know quick what I need to do.....

    I need to center the pasted chart so its not floating in the top left corner. Do I have to run a separate sub for this, or can I insert the formatting after I paste it in during the loop For i = 1 To ThisWorkbook.Sheets.Count
    ?

  9. #9
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Copy ranges from multiple worksheets in excel and then paste special in Powerpoint

    Hi MClarke,

    I've been looking for a way to insert "Destination:=" in the PasteSpecial line but have, so far, been thwarted - Sorry AND You're welcome!

  10. #10
    Registered User
    Join Date
    03-15-2013
    Location
    Toronto Canada
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Copy ranges from multiple worksheets in excel and then paste special in Powerpoint

    Hi, thats ok.


    Im not sure how to run multiple functions in these loops.

    It craps out, I think it wants me to run separate loops for each action or something. It WILL NOT select the shapes once they are pasted on the page, for some reason it hates them.

    Thanks again for your help!


  11. #11
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Copy ranges from multiple worksheets in excel and then paste special in Powerpoint

    Hi,

    See if this will see them:

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1