excel - Update PowerPoint chart using VBA -
i know question has been asked , answered many times, unfortunately can't find working solution.
so, have simple presentation in powerpoint (just 1 slide 1 chart created excel table) , need update recent data via vba, no matter excel or powerpoint script should run.
first of all, tried obvious script powerpoint:
sub update1() activepresentation.updatelinks end sub
it seems run made no changes. began search in web solutions , find, example, following topic on stackoverflow.
for answer optimistic busy run without errors , gives me output in messagebox, changes nothing in powerpoint chart.
for answer rinusp gives me error
run-time error '91': object variable or block variable not set
on line
for each sld in mypresentation.slides
i tried these macros in powerpoint.
i tried answers other questions on stackoverflow, unfortunately nothing works me. happy if helps me find working solution -- doesn't matter excel or powerpoint should vba script run.
thanks in advance.
update: i'm updating question complete examples of code have tried run. examples provided users optimistic busy , rinusp on mentioned above stackoverflow topic.
this code when run powerpoint gives me error "run-time error '91': object variable or block variable not set"
sub update2() dim mypresentation powerpoint.presentation dim sld powerpoint.slide dim shp powerpoint.shape dim mychart powerpoint.chart each sld in mypresentation.slides each shp in sld.shapes if shp.haschart set mychart = shp.chart mychart.chartdata.activate mychart.refresh end if next next end sub
and code runs without errors , gives output in message box, doesn't update chart
sub update3() dim sld slide, shp shape each sld in activepresentation.slides each shp in sld.shapes on error resume next shp.linkformat.update next next msgbox ("update chart") end sub
if run macro in powerpoint , chart linked, code work.
sub update2() dim mypresentation powerpoint.presentation dim sld powerpoint.slide dim shp powerpoint.shape dim mychart powerpoint.chart dim wb object dim app object set mypresentation = activepresentation each sld in mypresentation.slides each shp in sld.shapes if shp.haschart set mychart = shp.chart mychart.chartdata.activate mychart.refresh set wb = mychart.chartdata.workbook set app = wb.application wb.close (0) end if next next app.quit end sub
Comments
Post a Comment