我正在制作一个visula c ++项目,在某些方面我需要打开一个power point文件(特别是一个.ppsx文件)并能够启动,浏览幻灯片并关闭应用程序。
伪代码如下:
presentation = new Presentation("file.ppsx");
presentation.Start();
//do something
presentation.NextSlide();
//do something else
presentation.NextSlide();
//finally close it
presentation.Finish();
我真的很感谢代码执行此操作以及要包含的库。 提前谢谢!
答案 0 :(得分:1)
有一个库为ppt做这个。首先,生成更新的Office类型库(.tlh,.tli): 检查http://support.microsoft.com/kb/238972/以获取当前类型库文件名。
导入类型库,例如在VS C ++项目中(使用\):
#import "C:\\Program Files\\Common Files\\Microsoft Shared\\OFFICE12\\MSO.DLL" rename("RGB", "MSRGB")
#import "C:\\Program Files\\Common Files\\Microsoft Shared\\VBA\\VBA6\\VBE6EXT.OLB" raw_interfaces_only, rename("Reference", "ignorethis"), rename("VBE", "testVBE")
#import "C:\\Program Files\\Microsoft Office\\Office12\\MSPPT.OLB" exclude("IFont", "IPicture") rename("RGB", "ignorethis"), rename("DialogBox", "ignorethis"), rename("VBE", "testVBE"), rename("ReplaceText", "EReplaceText"), rename("CopyFile","ECopyFile"), rename("FindText", "EFindText"), rename("NoPrompt", "ENoPrompt")
编译。 Tlh / tli文件将在\ udebug或\ urelease中创建。 将它们复制到您的项目中。
在C ++中,尝试这样的事情。
PowerPoint::DesignPtr my_design= my_active_presentation->Designs->Load(as_bstr(template_filename), 1);
您可以在https://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint
下找到更多文档它可能无法直接帮助您,因为为时已晚。但它可以帮助其他人试图解决同样的问题。