Copy all tables and charts from all sheets of Excel to PowerPoint -


i need code snippet copy charts , tables excel file sheets powerpoint file using macro (vba) in excel.

below code copies charts. want copy tables , charts , images.

sub pushchartstoppt()  'set reference 'microsoft powerpoint 12.0 object library'  'in vbe via tools > references...  '  dim ppt powerpoint.application  dim pptpres powerpoint.presentation  dim pptsld powerpoint.slide  dim pptcl powerpoint.customlayout  dim pptshp powerpoint.shape   dim cht chart  dim ws worksheet  dim long   'get powerpoint application object:  set ppt = createobject("powerpoint.application")  ppt.visible = msotrue  set pptpres = ppt.presentations.add   'get custom layout:  each pptcl in pptpres.slidemaster.customlayouts      if pptcl.name = "title , content" exit  next pptcl   'copy charts in chart sheets:  each cht in activeworkbook.charts      set pptsld = pptpres.slides.addslide(pptpres.slides.count + 1, pptcl)      pptsld.select      each pptshp in pptsld.shapes.placeholders          if pptshp.placeholderformat.type = ppplaceholderobject exit      next pptshp      if pptshp nothing stop       cht.chartarea.copy      ppt.activate      pptshp.select      ppt.windows(1).view.paste  next cht   'copy charts embedded in each worksheet:  each ws in activeworkbook.worksheets      = 1 ws.chartobjects.count          set pptsld = pptpres.slides.addslide(pptpres.slides.count + 1, pptcl)          pptsld.select           each pptshp in pptsld.shapes.placeholders              if pptshp.placeholderformat.type = ppplaceholderobject exit          next pptshp          set cht = ws.chartobjects(i).chart          cht.chartarea.copy          ppt.activate          pptshp.select          ppt.windows(1).view.paste      next    next ws  end sub 

for pictures try using shapes how select pictures

dim pic shape each pic in activesheet.shapes     if pic.type = msopicture         pic.select         'do image     end if next pic 

Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -