BCB 播放PPT时遇到问题 请教大家
void __fastcall TForm1::Button2Click(TObject *Sender)
{
Variant vPowerPoint;
LPCTSTR lpFileName = "aa.ppt";
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);
vPowerPoint.OlePropertySet( "Visible ", false);
// 幻灯片总数
int nSlidesCount = vPowerPoint.OlePropertyGet( "ActivePresentation ").OlePropertyGet( "Slides ").OlePropertyGet( "Count ");
// 放映这个剪辑
vPowerPoint.OlePropertyGet( "ActivePresentation ").OlePropertyGet( "SlideShowSettings ").OleFunction( "Run ");
// 设置播放大小
//SetPptSize(); //还没有改变窗口大小的时候PPT会全屏显示
Variant vSlideShowWin = vPowerPoint.OlePropertyGet( "ActivePresentation ").OlePropertyGet( "SlideShowWindow ");
for(int i=0; i <nSlidesCount;i++)
{
// 下一个幻灯片
vSlideShowWin.OlePropertyGet( "View ").OleFunction( "Next ");
}
// 关闭Powerpoint
vPowerPoint.OleProcedure( "Quit ");
vPowerPoint = Unassigned;
}
编译没问题,但运行时提示“无效的类别字符串”,请大家过目。
[解决办法]
哪一行代码引起的,是不是
CreateOleObject( "PowerPoint.Application "); 多了个空格