Resizing a excel pasted object in powerpoint with vba -
i've cobbled vba script (i'm no expert, kind folks around here, i've been able , working) copy multiple excel sheets powerpoint file (used template, see code.
sub atestpptreport() dim ppapp powerpoint.application dim ppslide powerpoint.slide dim pppres powerpoint.presentation set ppapp = createobject("powerpoint.application") dim slidenum integer dim ppshape powerpoint.shape set xlapp = getobject(, "excel.application") ''define input powerpoint template dim strprespath string, strexcelfilepath string, strnewprespath string ''# change "strprespath" full path of powerpoint template strprespath = "c:\template.ppt" ''# change "strnewprespath" want save new presentation created strnewprespath = "c:\macro_output-" & format(date, "dd-mmm-yyyy") & ".ppt" set pppres = ppapp.presentations.open(strprespath) pppres.application.activate ppapp.visible = true ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''define destination slide slidenum = 1 pppres.slides(slidenum).select set ppshape = pppres.slides(slidenum).shapes("slide1box") set ppslide = pppres.slides(ppapp.activewindow.selection.sliderange.slideindex) ''define source sheet sheets("info1").activate 'copy/paste xlapp.range("info1block").copy ppslide.shapes.pastespecial datatype:=pppasteoleobject, link:=msofalse ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''define destination slide slidenum = 2 pppres.slides(slidenum).select ' set ppshape = pppres.slides(slidenum).shapes("slide2box") set ppslide = pppres.slides(ppapp.activewindow.selection.sliderange.slideindex) ''define source sheet sheets("info2").activate 'copy/paste xlapp.range("info2block").copy ppslide.shapes.pastespecial datatype:=pppasteoleobject, link:=msofalse ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' close presentation pppres.saveas strnewprespath 'pppres.close 'quit powerpoint 'ppapp.quit ' msgbox "presentation created", vbokonly + vbinformation ' clean set ppslide = nothing set pppres = nothing set ppapp = nothing end sub
my problem is: how resize/reposition object once it's been pasted?
the function "pastespecial" returns shape object, can use resize or reposition.
for example:
dim ppshape powerpoint.shape set ppshape = ppslide.shapes.pastespecial(datatype:=pppasteoleobject, link:=msofalse)
then can use shape object resize it. example:
ppshape.height = xyz ppshape.top = abc
etc etc.
hope helps. vikas b
Comments
Post a Comment