+ Reply to Thread
Results 1 to 5 of 5

Pasting an Excel range as a picture in PowerPoint

Hybrid View

arifb Pasting an Excel range as a... 05-26-2009, 01:44 PM
Andy Pope Re: Pasting an Excel range as... 05-27-2009, 05:04 AM
arifb Re: Pasting an Excel range as... 05-27-2009, 05:32 AM
Andy Pope Re: Pasting an Excel range as... 05-27-2009, 05:45 AM
arifb Re: Pasting an Excel range as... 05-27-2009, 07:02 AM
  1. #1
    Registered User
    Join Date
    05-26-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    3

    Pasting an Excel range as a picture in PowerPoint

    Hi,

    I am writing a C# application (.NET 3.5) to perform the following:

    1. Create a number of worksheets in an Excel 2007 workbook, each worksheet containing charts and associated text. The charts are created using the ChartWizard of the object model.
    2. Copy the charts and associated text as images and paste them on slides in a PowerPoint 2007 template

    I am attempting to do this via automation. The problem I am encountering is as follows:

    1. On a single worksheet, I have four charts, each with associated text (in the cells around the chart objects). I need to copy each chart, with its associated text, and paste each into a separate PowerPoint slide.
    2. I define a "Range" object to return the area encompassing the chart and its associated text. e.g. Worksheet.get_Range("A1", "N20")
    3. I then use the Range.CopyPicture() method to copy the contents of the range to the clipboard.
    4. Finally, I use the Slide.Shapes.Paste() method to paste the picture from the clipboard to a PowerPoint slide.

    This only works for the first of the four charts (or ranges). That is, only the first chart is copied along with its text and pasted as is on the slide. For the remaining three charts, only the corresponding text is pasted on the slide; the charts themselves are missing.

    Could someone please help me with this?

    Thanks a lot.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Pasting an Excel range as a picture in PowerPoint

    Do the ranges completely cover the chart objects?

    Does it work if you do it manually?
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    05-26-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Pasting an Excel range as a picture in PowerPoint

    Andy,

    Yes, the ranges specified completely cover the chart and its text. When I copy the range manually and do a "simple" paste in PowerPoint, I get the same behaviour (text but no chart). However, when I do a "Paste Special" and paste as an image, I get everything (text and chart).

    I have tried using the PasteSpecial() function in PowerPoint 2007 object model, but with no success.

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Pasting an Excel range as a picture in PowerPoint

    What if you copyaspicture in excel

    I don't do C# or .Net coding but in VBA

    Range("A1:D5").CopyPicture xlScreen ,xlBitmap
    And in powerpoint you can do something like
    activepresentation.slides(1).Shapes.PasteSpecial ppPasteBitmap

  5. #5
    Registered User
    Join Date
    05-26-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Pasting an Excel range as a picture in PowerPoint

    There are equivalents through the respective object models to the VBA functions you have mentioned, and this is exactly how I have been trying to do it.

    It appears that this forum may not be the ideal place to discuss the issue (as it involves .NET). I may try posting somewhere else. As a workaround in the meantime, I will spread the charts across separate worksheets (silly, but should work) and copy them that way.

    Thanks for your help :-)

+ 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