Solved

Using VBA to copy Excel range to PowerPoint table

Posted on 2014-01-02
3
4,752 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:versatilebb
3 Comments
 
LVL 48

Accepted Solution

by:
Rgonzo1971 earned 500 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:versatilebb
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

We were having a lot of "Heartbeat Alerts" in our SCOM environment, now "Heartbeat" in a SCOM environment for those of you who might not be familiar with SCOM is a packet of data sent from the agent to the management server on a regular basis, basic…
Preface: When I started this series, I used the term CommandBars because that is the Office Object class that it discusses. Unfortunately, when Microsoft introduced Office 2007, they replaced the standard Commandbar menus with "The Ribbon" and rem…
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…

708 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now