none
Copy Data from Excel to Powerpoint in VBA....

    Question

  • Hello

    I have been working most of the day trying to get Excel to talk to PowerPoint. I am on Version 2007..

    What I want to do is run a macro in Excel, have that macro copy a few columns then .COPY so it will be in the clip board.

    I then want to switch to PowerPoint and Paste-Special as a Windows Meta File.

    Does anyone have a short code snipit perhaps they could share?

    Thanks in advance.

    • Moved by Nick Wan Monday, July 04, 2011 8:11 AM VBA (From:Excel IT Pro Discussions)
    Saturday, July 02, 2011 5:49 AM

Answers

  • Hello kpierce63

    You would not require a 3rd party application/tool to achieve what you want. You can use VBA code to make that "Talking" happen between Excel and PowerPoint.

    I can give you the code but I want to see what have you tried till now. If you have not tried it and are unsure on how to proceed then follow this logic. Once you understand the logic, simply apply it and show the code that you tried and we will definitely help you if you get stuck :)

    LOGIC:

    1) Copy the relevent cells/columns in Excel

    2) Use Late/Early Binding in Excel to connect to PowerPoint. See this link to know more about Late/Early Binding.

    http://support.microsoft.com/kb/245115 (For Early binding in VBA, the reference has to be added from the VBA menu Tools ~~> References.)

    You can also see this site by Jon Peltier (MVP)

    http://peltiertech.com/Excel/XL_PPT.html

    3) Navigate to the relevant slide if required and paste the data in the required format.

    Hope this helps :)


    Sid

    Monday, July 04, 2011 6:38 PM
    Moderator
  • Go through the Following link to see how to develop macro to transfer data from excel to a powrrpoint

    Automating a Powerpoint Presentation using VBA

    http://www.mahipalreddy.com/vba/ppvba.htm

     


    Ankur Chakravarty Hyderabad
    • Marked as answer by Bruce Song Monday, July 18, 2011 11:49 AM
    Tuesday, July 05, 2011 6:04 PM
  • Hi Kpierce63,

    What is the status of the problem on your side? Do the suggestions help you? I coded the following snippet which can copy content from Excel and paste into Powerpoint side as Meta file:

     

    Sub copydata()

    Const ppLayoutBlank = 12

     

    Dim objWorkSheet As Worksheet

    Dim objRange As Range

    Set objWorkSheet = ThisWorkbook.ActiveSheet

    Set objRange = objWorkSheet.UsedRange

    objRange.Copy

     

    Dim objPPT As PowerPoint.Application

    Dim objPresentation As Presentation

    Set objPPT = CreateObject("PowerPoint.Application")

    objPPT.Visible = True

     

    Set objPresentation = objPPT.Presentations.Add

    Set objSlide = objPresentation.Slides.Add(1, 1)

     

    objPresentation.Slides(1).Layout = ppLayoutBlank

     

    ' paste as the meta file

    objPPT.Windows(1).View.PasteSpecial ppPasteMetafilePicture, msoTrue, , , "testlabel"

    objPresentation.SaveAs "D:\MyPres.pptx"

    End Sub

    Hope this can help you and just feel free to follow up after you have tried and rember to add the reference Powerpoint Object Library.

    Best Regards,


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    • Marked as answer by Bruce Song Monday, July 18, 2011 11:49 AM
    Thursday, July 07, 2011 8:44 AM

All replies

  • Hello

    I have been working most of the day trying to get Excel to talk to PowerPoint. I am on Version 2007..

    What I want to do is run a macro in Excel, have that macro copy a few columns then .COPY so it will be in the clip board.

    I then want to switch to PowerPoint and Paste-Special as a Windows Meta File.

    Does anyone have a short code snipit perhaps they could share?

    Thanks in advance.

     

    • Merged by William Zhou CHN Wednesday, July 06, 2011 5:47 AM Coding for Developer
    Saturday, July 02, 2011 5:48 AM
  • Try maybe EzPaste (www.ezpaste.net) that will dot this and much much more...

    Best regards and good luck

    Avi

     

    Monday, July 04, 2011 3:41 PM
  • Hello kpierce63

    You would not require a 3rd party application/tool to achieve what you want. You can use VBA code to make that "Talking" happen between Excel and PowerPoint.

    I can give you the code but I want to see what have you tried till now. If you have not tried it and are unsure on how to proceed then follow this logic. Once you understand the logic, simply apply it and show the code that you tried and we will definitely help you if you get stuck :)

    LOGIC:

    1) Copy the relevent cells/columns in Excel

    2) Use Late/Early Binding in Excel to connect to PowerPoint. See this link to know more about Late/Early Binding.

    http://support.microsoft.com/kb/245115 (For Early binding in VBA, the reference has to be added from the VBA menu Tools ~~> References.)

    You can also see this site by Jon Peltier (MVP)

    http://peltiertech.com/Excel/XL_PPT.html

    3) Navigate to the relevant slide if required and paste the data in the required format.

    Hope this helps :)


    Sid

    Monday, July 04, 2011 6:38 PM
    Moderator
  • Go through the Following link to see how to develop macro to transfer data from excel to a powrrpoint

    Automating a Powerpoint Presentation using VBA

    http://www.mahipalreddy.com/vba/ppvba.htm

     


    Ankur Chakravarty Hyderabad
    • Marked as answer by Bruce Song Monday, July 18, 2011 11:49 AM
    Tuesday, July 05, 2011 6:04 PM
  • Hi Kpierce63,

    What is the status of the problem on your side? Do the suggestions help you? I coded the following snippet which can copy content from Excel and paste into Powerpoint side as Meta file:

     

    Sub copydata()

    Const ppLayoutBlank = 12

     

    Dim objWorkSheet As Worksheet

    Dim objRange As Range

    Set objWorkSheet = ThisWorkbook.ActiveSheet

    Set objRange = objWorkSheet.UsedRange

    objRange.Copy

     

    Dim objPPT As PowerPoint.Application

    Dim objPresentation As Presentation

    Set objPPT = CreateObject("PowerPoint.Application")

    objPPT.Visible = True

     

    Set objPresentation = objPPT.Presentations.Add

    Set objSlide = objPresentation.Slides.Add(1, 1)

     

    objPresentation.Slides(1).Layout = ppLayoutBlank

     

    ' paste as the meta file

    objPPT.Windows(1).View.PasteSpecial ppPasteMetafilePicture, msoTrue, , , "testlabel"

    objPresentation.SaveAs "D:\MyPres.pptx"

    End Sub

    Hope this can help you and just feel free to follow up after you have tried and rember to add the reference Powerpoint Object Library.

    Best Regards,


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    • Marked as answer by Bruce Song Monday, July 18, 2011 11:49 AM
    Thursday, July 07, 2011 8:44 AM
  • Hello.  I have read your replies from 2011 to Kpierce63.  I have a similar situation.  I have developed several hundred data tables and line charts in Excel referring to New Jersey and its 21 counties.  I am analyzing treatment admissions data by several different factors and projecting 8 years of data over six additional years.  I am preparing powerpoint slide shows. Each county will get their own. I have a template of one county. 

    In excel, I constructed the New Jersey table and the 21 county tables for each factor so that the tables are stacked vertically. Then, I moved horizontally across the worksheet and produced another such "stack" for another factor.  

    Now, I want to write a macro in Excel that will copy each table into the correct county powerpoint presentation and to the correct, that is, corresponding slide, replacing the content of the template slide, without disturbing its layout or shape formatting.  Could you help me to do this?  I will begin with the code you wrote for Kpierce63 and go from there.  Thank you for your help.  Boboloui62.  

    Sunday, December 29, 2013 11:55 PM
  • This is the best resource I have ever seen for using PowePoint and Excel together.

    http://www.pptfaq.com/index.html


    Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.

    Tuesday, December 31, 2013 3:26 AM