可以将形状分组,以便它们作为一个单元来工作。如果你经常使用它们,组合形状很有用。本文将介绍如何在powerpoint幻灯片中创建组合形状。
c#
//创建powerpoint文档
presentation ppt = new presentation();
//获取第一张幻灯片
islide slide= ppt.slides[0];
//添加一个矩形
ishape rectangle = slide.shapes.appendshape(shapetype.rectangle, new rectanglef(20, 100, 200, 40));
rectangle.fill.filltype = fillformattype.solid;
rectangle.fill.solidcolor.knowncolor = knowncolors.gold;
rectangle.line.width = 0.1f;
//添加一个带状形状
ishape ribbon = slide.shapes.appendshape(shapetype.ribbon2, new rectanglef(60, 75, 120, 80));
ribbon.fill.filltype = fillformattype.solid;
ribbon.fill.solidcolor.knowncolor = knowncolors.purple;
ribbon.line.width = 0.1f;
//将两个形状添加到arraylist数组
arraylist list = new arraylist();
list.add(rectangle);
list.add(ribbon);
//组合数组中的形状
ppt.slides[0].groupshapes(list);
//保存文档
ppt.savetofile("output.pptx", fileformat.pptx2010);
vb.net
'创建powerpoint文档
dim ppt as new presentation()
'获取第一张幻灯片
dim slide as islide = ppt.slides(0)
'添加一个矩形
dim rectangle as ishape = slide.shapes.appendshape(shapetype.rectangle, new rectanglef(20, 100, 200, 40))
rectangle.fill.filltype = fillformattype.solid
rectangle.fill.solidcolor.knowncolor = knowncolors.gold
rectangle.line.width = 0.1f
'添加一个带状形状
dim ribbon as ishape = slide.shapes.appendshape(shapetype.ribbon2, new rectanglef(60, 75, 120, 80))
ribbon.fill.filltype = fillformattype.solid
ribbon.fill.solidcolor.knowncolor = knowncolors.purple
ribbon.line.width = 0.1f
'将两个形状添加到arraylist数组
dim list as new arraylist()
list.add(rectangle)
list.add(ribbon)
'组合数组中的形状
ppt.slides(0).groupshapes(list)
'保存文档
ppt.savetofile("output.pptx", fileformat.pptx2010)