在C#中使用PowerPoint设置圆角矩形半径,可以通过以下步骤实现:
Application
类创建一个PowerPoint应用程序对象。using Microsoft.Office.Interop.PowerPoint;
Application pptApplication = new Application();
Presentations
类打开一个PPT文件。Presentations presentations = pptApplication.Presentations;
Presentation presentation = presentations.Open("C:\\Path\\to\\Your.pptx");
Slides
类获取幻灯片对象。Slides slides = presentation.Slides;
Slide slide = slides[1]; // 获取第一张幻灯片
Shapes
类添加一个圆角矩形形状。Shapes shapes = slide.Shapes;
Shape shape = shapes.AddShape(MsoAutoShapeType.msoShapeRoundedRectangle, left, top, width, height);
这里,left
、top
、width
、height
是圆角矩形的位置和大小参数。
Shape
对象的Adjustments
属性设置圆角矩形的圆角半径。Adjustments adjustments = shape.Adjustments;
adjustments.Item[1] = radius; // 设置圆角半径
这里,radius
是圆角矩形的圆角半径值。
presentation.Save();
presentation.Close();
完整的代码示例:
using Microsoft.Office.Interop.PowerPoint;
Application pptApplication = new Application();
Presentations presentations = pptApplication.Presentations;
Presentation presentation = presentations.Open("C:\\Path\\to\\Your.pptx");
Slides slides = presentation.Slides;
Slide slide = slides[1];
Shapes shapes = slide.Shapes;
Shape shape = shapes.AddShape(MsoAutoShapeType.msoShapeRoundedRectangle, left, top, width, height);
Adjustments adjustments = shape.Adjustments;
adjustments.Item[1] = radius;
presentation.Save();
presentation.Close();
这样,你可以使用C#在PowerPoint中设置圆角矩形半径。如果你想了解更多关于PowerPoint的操作,可以参考腾讯云的Microsoft.Office.Interop.PowerPoint
相关产品文档:https://cloud.tencent.com/document/product/1042
领取专属 10元无门槛券
手把手带您无忧上云