Copy Excel chart to PowerPoint with embedded data using VBA -
after pasting chart in excel, there's "smart tag" pops in bottom right of chart, 1 can select "excel chart (entire workbook)" (as opposed default "chart (linked excel data)"). has effect of embedding data in chart data can still modified, chart not linked excel file. has been able replicate using vba (using either in excel-vba or powerpoint-vba)?
i haven't found way programmatically access "smart tag" vba. moreover, paste special options not seem have option this.
i'm using office 2007.
try tahlor:
option explicit ' =========================================================================================== ' copy specified chart powerpoint whilst maintaining data link. ' written : jamie garroch of youpresent ltd. (uk) ' date : 08 july 2015 ' more amazing powerpoint stuff visit @ http://youpresent.co.uk/ ' =========================================================================================== ' copyright (c) 2015 youpresent ltd. ' source code provide under creative commons attribution license ' means must give credit our original creation in following form: ' "includes code created youpresent ltd. (youpresent.co.uk)" ' commons deed @ http://creativecommons.org/licenses/by/3.0/ ' license legal @ http://creativecommons.org/licenses/by/3.0/legalcode ' =========================================================================================== ' macro execution environment : designed run in excel vba. ' =========================================================================================== ' can use binding (with advantage intellisense adds) adding reference ' powerpoint object library , setting compiler constant earlybinding true ' delete afterwards otherwise face nightmare of compatibility!!! ' =========================================================================================== #const earlybinding = false sub copypastelinkedcharttopowerpoint() #if earlybinding ' define binding powerpoint objects can use intellisense while debuggging ' requires reference (tools/references) microsoft powerpoint xx.y object library dim oppt powerpoint.application dim opres powerpoint.presentation dim osld powerpoint.slide #else ' define late binding powerpoint objects ' remove reference microsoft powerpoint object library dim oppt object dim opres object dim osld object const pplayouttitle = 1 #end if ' define excel objects dim owb workbook dim ows worksheet dim ocht chartobject set oppt = createobject("powerpoint.application") set opres = oppt.presentations.add(msotrue) set osld = opres.slides.add(1, pplayouttitle) ' modify these lines according how want selet chart set owb = activeworkbook set ows = owb.worksheets(1) set ocht = ows.chartobjects(1) ocht.select activechart.chartarea.copy ' paste chart powerpoint slide data link osld.shapes.pastespecial link:=msotrue ' clear objects set oppt = nothing: set opres = nothing: set osld = nothing set owb = nothing: set ows = nothing: set ocht = nothing end sub
Comments
Post a Comment