Keep Source Formatting pasting charts from Excel to PowerPoint using VBA
Posted on 2011-10-16
I'm working on a project where I'm batch-producing presentations in PowerPoint - embedding charts created in Excel 2010 using VBA. The charts are set up in Excel and the data populated there via VBA. Once done, a PowerPoint template is opened (from within the program) and, one by one, the charts are copied and pasted into the presentation. (The program runs from Excel and setups up a PowerPoint object to manipulate the presentation.)
Easy enough, right?
PowerPoint 2010 annoyingly wants to apply the template's formatting to the charts. I can manually right-click and select "Keep Source Formatting and Embed Chart" to get it to keep the source color scheme (which I want), but I can't seem to find any way to replicate this using VBA. I've gone through all the .PasteSpecial options, but none seem to duplicate the shortcut menu option mentioned above. The closest I can come is the ppPasteOLEObject, but the result is pretty grainy, and requires the user to double-click on the chart to open and edit it (which they want to be able to do). Using the "Keep Source Formatting..." option above allows you to edit the chart directly, as if a native object.
Does anyone know if this command is replicable using VBA, or if not? I've discovered that the key-combination to do this is Alt+H+V+K - and I was thinking of trying to use SendKeys, but it doesn't seem to work applying it against the PowerPoint application reference in my code (i.e., PPApp.SendKeys - gives and error).
Thanks much for any help!