前段时间突然接一小项目,其实也就是一个实例罢了,要求将程序中的位图按照一定的格式写入PowerPoint当中,经过自己的一番推敲终于搞定今天将具体的操作记录在此,方便今后改进。
环境及软件配置:
(1)PowerPoint2003
(2)VC 6.0.
操作步骤:
首先新建一简单的MFC 对话框应用程序,在其中增加一按钮方便我们测试,双击按钮添加按钮处理事件。
打开类向导对话框;AddClass->from a library->切换至PowerPoint安装目录寻找:MSPPT.OLB文件,由于我是默认安装所以在目录:C:\Program Files\Microsoft Office\OFFICE11 中 选中此文件后打开confirm Classes对话框 按住键盘ctrl依次选择:Application.SlideShowWindow,Selection,Fonts,Slides,SlideRange,RGBColor等我们需要操作的类, 然后给文件命名即可。
在button事件所在文件中包含新增加的文件。
然后写入如下代码:
void CTestpptDlg::OnButton1()
{
// Commonly used OLE-variants.
COleVariant
covTrue((short)TRUE),
covFalse((short)FALSE),
covOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR);
_Application app;
Presentations presentations;
_Presentation presentation;
Slides slides;
_Slide slide;
ShapeRange shaperange;
Shapes shapes;
Shape shape;
TextFrame textframe;
TextRange textrange;
Font font;
FillFormat fillformat;
ColorFormat colorformat;
ShadowFormat shadow;
CString strPic1 ="C:\\Program Files\\Micro