Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Using VBA to copy Excel range to PowerPoint table

Posted on 2014-01-02
3
Medium Priority
?
5,436 Views
Last Modified: 2014-01-03
Hi Experts:

I've done lots of automation between Excel and PowerPoint, including copying Chart objects and copying Excel data into the data table behind a PowerPoint Chart.  

But I can't figure this one out.  Using VBA I want to copy a formatted Excel range into a PowerPoint TABLE.  I want to duplicate what I get when I manually copy the range, then manually paste into PPT, selecting the Keep Source Formatting option.  It's a heat map, so very important to preserve formatting.

Once it's in PowerPoint, I need to be able to further manipulate the table, changing font sizes, adding rows, etc. all of which I know how to do.  Where I'm stuck is getting it to come in as a table.

The following two options both copy the formatting of the source cells, but in one case it's just a picture and in another it's an OLE object I can't manipulate

PPSlide.Shapes.PasteSpecial DataType:=ppPasteEnhancedMetafile
PPSlide.Shapes.PasteSpecial DataType:=ppPasteOLEObject

Open in new window

In the past I've iterated through the range and copied the values into the cells of the PowerPoint table one at a time, but there has to be a better way.

Thanks for your suggestions.
0
Comment
Question by:Bryce Bassett
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 53

Accepted Solution

by:
Rgonzo1971 earned 2000 total points
ID: 39753168
Hi,

pls try

ActivePresentation.Application.CommandBars.ExecuteMso ("PasteSourceFormatting")

Open in new window

Regards
0
 
LVL 23

Expert Comment

by:JSRWilson
ID: 39753227
As Rgonzo says "PasteSourceFormatting" models pressing the Keep SAource Format button. It only runs from version 2010.

You will probably need to select the start cell of the table first.

Assuming otbl is a reference to the table and the start cell is 2,2

otbl.Cell(2, 2).Select
CommandBars.ExecuteMso ("PasteSourceFormatting")
0
 

Author Closing Comment

by:Bryce Bassett
ID: 39754528
I knew there was an easier way.  Thanks!

JSR, I didn't use your suggestion of selecting the table cell.  That does not appear to be necessary.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question