OFN_PATHMUSTEXIST,szFilter);
FileDlg.DoModal();
// To get the selected file's path and name
CString strFileName;
strFileName = FileDlg.GetPathName();
if(!strFileName.IsEmpty())
{
Presentations = app.GetPresentations();
Presentation = Presentations.Open(strFileName,0,0,1);
}
}
(8) 为关闭POWERPOINT,在CLOSE按钮函数呼叫中添加代码:
void CPowerPntDlg::OnBtnClose()
{
if (CanExit())
app.Quit();
}
在步骤7,8,9中的函数是你需要知道应用程序的基本处理。
现在我们有了运行的POWERPOINT且有了准备,我们需要用它做一些事情像运行幻灯片放映和执行其他行为。
现在让我们运行幻灯片放映。
(9) 为运行幻灯片放映,在RUN按钮函数呼叫中添加代码:
void CPowerPntDlg::OnBtnRun()
{
Presentations = app.GetActivePresentation();
slides = Presentation.GetSlides();
// Show the first slide of the presentation
slide = slides.Item(COleVariant((long)1));
//Run the show
slideshow = Presentation.GetSlideShowSettings();
slideshow.Run();
}
(10) 有时,你可能想从第一张幻灯片中启动全部。要到第一张幻灯片你可以使用这些代码:
void CPowerPntDlg::OnBtnFirst()
{
Presentation = app.GetActivePresentation();
SlideShowWindow = Presentation.GetSlideShowWindow();
View = SlideShowWindow.GetView();
View.First();
}
(11) 相似地,到最后一张幻灯片:
void CPowerPntDlg::OnBtnLast()
{
Presentation = app.GetActivePresentation();
SlideShowWindow = Presentation.GetSlideShowWindow();
View = SlideShowWindow.GetView();
View.Last();
}
(12) 既然你有了运行的幻灯片放映,你显然会在一些时间点上回到上一张幻灯片。要这样做,使用下列代码:
void CPowerPntDlg::OnBtnPrevious()
{
Presentation = app.GetActivePresentation();
SlideShowWindow = Presentation.GetSlideShowWindow();
View = SlideShowWindow.GetView();
View.Previous();
}
(13) 现在有兴趣到下一张幻灯片?在这种情况下,这个函数会帮助你:
void CPowerPntDlg::OnBtnNext()
{
Presentation = app.GetActivePresentation();
SlideShowWindow = Presentation.GetSlideShowWindow();
View = SlideShowWindow.GetView();
View.Next();
}
这就是了,伙计。检查出其他转变,动画制作等的可用函数。你可以用你特有的方式进行。
这是基本框架,你可以看出它处理POWERPOINT是多么容易。用在WORD,EXCEL和其它MS-OFFICE上也是一会事。祝好运和快乐!
……