问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501

请问如何用VC编程powerpoint啊,需要的控制参数是什么啊

发布网友 发布时间:2022-04-22 10:05

我来回答

1个回答

热心网友 时间:2023-10-31 18:04

Introction
This tutorial helps you to learn the basics of automation. With this code,
you can control PowerPoint from your application. You can open PowerPoint
programmatically, open any presentation, go to any slide that you want to, run
the slideshow etc.
Steps to follow
<P>By following the same steps given below, you can automate , word, excel or
any Microsoft office application.</P>
<OL>
<LI>Create a dialog based application and in the App-wizard's step 3 of 6,
select the automation checkbox.
<LI>Create buttons for Start , Run, Close, First Slide, Last Slide, Previous
Slide and Next Slide functions and use the following functions accordingly.
<LI>In your application's <CODE>InitInstance</CODE> function , add the following
lines. <PRE>// Initialize OLE libraries
if (!AfxOleInit())
{
AfxMessageBox("Failed to initialize OLE");
return FALSE;
}</PRE>
<LI>In your dialog's class , open class-wizard , select the automation tab,
select "Add Class" ... "From a type library" and select <I>msppt8.olb</I> from
"<I>C:\Program Files\Microsoft Office\Office\</I>"
<LI>In your header file of your dialog, include the following line. <PRE>#include "msppt8.h"</PRE>
<LI>Add the following variables in your dialog's header file. <PRE>_Application app; // app is the PowerPoint _Application object

Presentations Presentations;
_Presentation Presentation;

SlideShowView View;

SlideShowWindow SlideShowWindow;
SlideShowSettings slideshow;
Slides slides;
_Slide slide;</PRE>
<LI>To start PowerPoint, you have to write this code in the Start button's
function. <PRE>void CPowerPntDlg::OnBtnStart()
{
// Start PowerPoint and get Application object...
if(!app.CreateDispatch("Powerpoint.Application"))
{
AfxMessageBox("Couldn't start PowerPoint.");
}
else // Make PowerPoint visible and display a message
{
app.SetVisible(TRUE);
TRACE("PowerPoint is Running!");
}
}</PRE>
<LI>To open a presentation from the hard disk, add this code in the Open
button's function call. <PRE>void CPowerPntDlg::OnBtnOpen()
{
static char BASED_CODE szFilter[] = "PowerPoint Files (*.ppt)|*.ppt||";
CFileDialog FileDlg(TRUE,"PPT",NULL,OFN_FILEMUSTEXIST|OFN_NONETWORKBUTTON
|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);
}
}</PRE>
<LI>To close PowerPoint add this code in the Close button's function call. <PRE>void CPowerPntDlg::OnBtnClose()
{
if (CanExit())
app.Quit();
}</PRE>
<LI>To run the slideshow use this code in the Run button's function call <PRE>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();
}</PRE>
<LI>Sometimes, you might want to start all over from the first slide. To go to
the first slide you can use this code. <PRE>void CPowerPntDlg::OnBtnFirst()
{
Presentation = app.GetActivePresentation();
SlideShowWindow = Presentation.GetSlideShowWindow();
View = SlideShowWindow.GetView();
View.First();
}</PRE>
<LI>And similarly, to go to the last slide <PRE>void CPowerPntDlg::OnBtnLast()
{
Presentation = app.GetActivePresentation();
SlideShowWindow = Presentation.GetSlideShowWindow();
View = SlideShowWindow.GetView();
View.Last();
}</PRE>
<LI>Now that you have the slideshow running, you would obviously want to go to
the previous slide at some point of time. To do just that, you can use this
code. <PRE>void CPowerPntDlg::OnBtnPrevious()
{
Presentation = app.GetActivePresentation();
SlideShowWindow = Presentation.GetSlideShowWindow();
View = SlideShowWindow.GetView();
View.Previous();
}</PRE>
<LI>Interested to go to the next slide now ? In that case, this function will
help you.<PRE>void CPowerPntDlg::OnBtnNext()
{
Presentation = app.GetActivePresentation();
SlideShowWindow = Presentation.GetSlideShowWindow();
View = SlideShowWindow.GetView();
View.Next();
}
声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com
iOS 16.1.1值得更新升级吗 ios16.1.1正式版建议更新吗 iOS 16.1.1修复了哪些问题 ios16.1.1值得更新吗?ios 16.1.1新增内容及更新建议 iPhone 12升级iOS 16.1.1之后好用吗 iOS 16.1.1更新内容介绍 iOS 16.1正式版新增了哪些新功能?iOS 16.1正式版值得升级吗? ios 16.1正式版解决了哪些问题和BUG ...森先生是他“最好的老师” 你喜欢这样的老师吗? ... 你喜欢怀特森这样老师吗?说说你的看法.250字 word拆分单元格后单元格会变大,怎么让它不变? win7是旗舰版吗? 神魔大陆“极速下载器”快还是“HPPT高速下载”快 HPPT代理服务器的IP地址和端口检测 为什么我家的电脑老是打不开网页呢? hppt协议可以获取电脑哪些硬件信息 急求DI-504登不进hppt://192.168.0.1的解决办法? 没hppt:// 上不了网 狼人杀怎么玩 请问hppt错误 12152怎么解决呢? 高二时制作的ppt重要吗H 苹果手机下载ppt格式报错H_404_-28124怎么解决? 关于美景的四字词语 描写景色的四字词 关于风景的四字成语。 描写美景的四字词语大全 微信上方有个红点怎么去掉? 微信怎么点名 关于美景的四字成语 flash player 安装失败 Microsoft Visual Studio 2008详细资料大全 win10耳机插电脑说不了话 为什么我的电脑耳麦可以听到声音,麦克风却说不到话 win10电脑中的耳机麦克风无法使用怎么办 您好,我想问您一个问题: 同事群聊名称创意点的有哪些? 一个组的同事微信群名起什么好呢 一起工作的同事群名搞笑有什么? 退休同事微信群 名字怎样取? 老同事微信群取什么名称,请帮助取个好听点的名字? 以前在一起工作的同事现在取微信群名字怎样取好? 微信同事群名字起什么名字好 同事群名称大全霸气十足的 同事微信怎么备注 微信同事群聊名 微信红包显示己超时发不走怎么回事? 微信红包超时没退怎么办? 微信红包超时末收退敦要收多少手续费?归谁收? 发微信红包总是等待超时 春天的柿子树是怎样的?