用OLE操作PowerPoint,如何获得当前幻灯片的编号?
下面是老妖(ccrun)的代码:
用OLE操作PowerPoint
void __fastcall TestPowerPoint(LPSTR lpFileName)
{
Variant vPowerPoint;
try
{
vPowerPoint = CreateOleObject( "PowerPoint.Application ");
}
catch(...)
{
ShowMessage( "Error... ");
}
// 使 Powerpoint 界面可视
vPowerPoint.OlePropertySet( "Visible ", true);
// Powerpoint的版本
String strVersion = vPowerPoint.OlePropertyGet( "Version ");
// 打开一个剪辑
vPowerPoint.OlePropertyGet( "Presentations ")
.OleFunction( "Open ", lpFileName, false, false, true);
// 幻灯片总数
int nSlidesCount = vPowerPoint.OlePropertyGet( "ActivePresentation ")
.OlePropertyGet( "Slides ").OlePropertyGet( "Count ");
// 放映这个剪辑
vPowerPoint.OlePropertyGet( "ActivePresentation ")
.OlePropertyGet( "SlideShowSettings ").OleFunction( "Run ");
// 下一个幻灯片
Variant vSlideShowWin = vPowerPoint.OlePropertyGet( "ActivePresentation ")
.OlePropertyGet( "SlideShowWindow ");
vSlideShowWin.OlePropertyGet( "View ").OleFunction( "Next ");
// 跳到第二页
vSlideShowWin.OlePropertyGet( "View ").OleFunction( "GoToSlide ", 2);
// 返回上一页
vSlideShowWin.OlePropertyGet( "View ").OleFunction( "Previous ");
// 跳到最后一页
vSlideShowWin.OlePropertyGet( "View ").OleFunction( "Last ");
// 显示当前幻灯名称
String strSlideName = vSlideShowWin.OlePropertyGet( "View ")
.OlePropertyGet( "Slide ").OlePropertyGet( "Name ");
// 运行某个宏
vPowerPoint.OleFunction( "Run ", " '1.ppt '!Macro1 ");
// 关闭Powerpoint
vPowerPoint.OleProcedure( "Quit ");
vPowerPoint = Unassigned;
}
在这过程中,如何获得当前幻灯片的编号?
[解决办法]
学习下