我使用C#创建了一个PowerPoint演示文稿:
PowerPoint.Application powerpointApplication;
PowerPoint.Presentation pptPresentation;
PowerPoint.Slide Slide;
// Create an instance of PowerPoint.
powerpointApplication = new PowerPoint.ApplicationClass();
// Create a PowerPoint presentation.
pptPresentation = powerpointApplication.Presentations.Add(
Microsoft.Office.Core.MsoTriState.msoTrue);
// Create empty slide
Slide = pptPresentation.Slides.Add(1, PowerPoint.PpSlideLayout.ppLayoutBlank);
TextRange objTextRng = objSlide.Shapes[1].TextFrame.TextRange;
objTextRng.Text = "Remote sensing calendar 1";
objTextRng.Font.Name = "Comic Sans MS";
objTextRng.Font.Size = 48;
// TODO: change color
// objTextRng.Font.Color
// Save presentation
pptPresentation.SaveAs( BasePath + "result\\2_example.ppt",
PowerPoint.PpSaveAsFileType.ppSaveAsDefault,
MsoTriState.msoTrue // TODO: что за параметр???
);
pptPresentation.Close();现在,我如何更改objTextRng的字体颜色
发布于 2011-03-09 22:27:41
下面的代码将字体颜色设置为红色:
objTextRng.Font.Color.RGB = Color.Red.ToArgb();如果要指定不同的颜色,可以使用其他pre-defined colors之一,或使用Color.FromArgb method指定您自己的RGB值。
无论采用哪种方法,都要确保在所使用的Color对象上调用ToArgb method。RGB属性要求指定RGB颜色值。
发布于 2012-01-04 06:54:29
将此用于PPTX 2007
private int BGR(Color color)
{
// PowerPoint's color codes seem to be reversed (i.e., BGR) not RGB
// 0x0000FF produces RED not BLUE
// 0xFF0000 produces BLUE not RED
// so we have to produce the color "in reverse"
int iColor = color.R + 0xFF * color.G + 0xFFFF * color.B;
return iColor;
}例如
shape.TextFrame.TextRange.Font.Color.RGB = BGR(Color.Red); 发布于 2011-03-09 22:33:50
我想this MSDN page会解释的。
EDIT:,但这只解释了如何在VBScript中进行编辑。您可以看到TextRange对象有一个属性Font。这将返回Font对象describe here这些资源显示您有权访问RGB属性。你可以按照科迪告诉你的那样设置。如果您需要更多信息,请参阅MSDN部分,我只是给您指出。
https://stackoverflow.com/questions/5247135
复制相似问题