为什么我用VC控制powerpoint 总是不成功啊?

作者&投稿:汗达 (若有异议请与网页底部的电邮联系)
VC操作Powerpoint,该怎么解决~

你的线程是非mfc的吧,最好的处理方法就是在你的线程中向对话框发送消息,在对话框主线程中接收消息进行处理~

PPT是微软OFFICE办公软件的组件之一,没有单独的产品。
微软OFFICE2010是商业软件,售价不菲,没有人会免费拿给你的,网上找得到的,都是盗版,几乎没有能用的。
建议从官方网站下载WPS OFFICE 2010个人版。相当好用,与微软的产品高度兼容,支持对OFFICE 2007/2010格式对的读取,更重要的是,官承诺对个人用户完全免费,不会产生版权问题。

手头没有头文件,不知道为什么,不过这儿有另一篇,看看是不是你office版本问题:
This article was previously published under Q222960
SUMMARY
This article describes how to automate Microsoft PowerPoint by using Visual C++ 5.0 or Visual C++ 6.0 with The Microsoft Foundation Classes (MFC).
MORE INFORMATION
By using automation in PowerPoint, you can programmatically print, display slides, and do most of the things you can do interactively. Follow these steps to build and run the automation example:
1. Create a new dialog-based MFC EXE project.
2. Add a button to your dialog box and a BN_CLICKED-handler for it.
3. Open ClassWizard (Ctrl+W), click the Automation tab, click Add Class, and select From a type library.
4. Go to the directory where you installed Office (for example, C:\Program Files\Microsoft Office\Office) and choose Msppt8.olb. The PowerPoint object library for PowerPoint 2000 is named Msppt9.olb. The PowerPoint object library for PowerPoint 2002 is Msppt.olb, and it is located, by default, in the c:\Program Files\Microsoft Office\Office10 folder. The PowerPoint object library for Microsoft Office PowerPoint 2003 is Msppt.olb, and it is located, by default, in the c:\Program Files\Microsoft Office\Office11 folder
5. Select all the classes it finds, and click OK to get back to your project. ClassWizard has generated some automation "wrapper classes" from the PowerPoint type library and created the files Msppt8.h and Msppt8.cpp.
6. Add the following code to your button handler:// Start PowerPoint.
_Application app;
COleException e;
if(!app.CreateDispatch("Powerpoint.Application", &e)) {
CString str;
str.Format("CreateDispatch() failed w/err 0x%08lx", e.m_sc),
AfxMessageBox(str, MB_SETFOREGROUND);
return;
}

// Make it visible.
app.SetVisible(TRUE);

// Get Presentations collection and add a new presentation.
Presentations presSet(app.GetPresentations());
_Presentation pres(presSet.Add(TRUE));

// Get Slides collection and add a new slide.
Slides slideSet(pres.GetSlides());
_Slide slide1(slideSet.Add(1, 2));

// Add text to slide, by navigating the slide as follows:
// slide1.shapes(#).TextFrame.TextRange.Text
{
Shapes shapes(slide1.GetShapes());
Shape shape(shapes.Item(COleVariant((long)1)));
TextFrame textFrame(shape.GetTextFrame());
TextRange textRange(textFrame.GetTextRange());
textRange.SetText("My first slide");
}
{
Shapes shapes(slide1.GetShapes());
Shape shape(shapes.Item(COleVariant((long)2)));
TextFrame textFrame(shape.GetTextFrame());
TextRange textRange(textFrame.GetTextRange());
textRange.SetText("Automating PowerPoint is easy\r\n"
"Using Visual C++ is powerful!");
}

// Add another slide with a chart.
_Slide slide2(slideSet.Add(2, 5));

// Add text to slide as before.
{
Shapes shapes(slide2.GetShapes());
Shape shape(shapes.Item(COleVariant((long)1)));
TextFrame textFrame(shape.GetTextFrame());
TextRange textRange(textFrame.GetTextRange());
textRange.SetText("Slide 2's topic");
}
{
Shapes shapes(slide2.GetShapes());
Shape shape(shapes.Item(COleVariant((long)2)));
TextFrame textFrame(shape.GetTextFrame());
TextRange textRange(textFrame.GetTextRange());
textRange.SetText("You can create and use charts "
"in your PowerPoint slides!");
}

// Add a chart where the default one was created.
{
// First get coordinates of old chart.
float cTop, cWidth, cHeight, cLeft;
Shapes shapes(slide2.GetShapes());
Shape shape(shapes.Item(COleVariant((long)3)));
cTop = shape.GetTop();
cWidth = shape.GetWidth();
cHeight = shape.GetHeight();
cLeft = shape.GetLeft();

// Delete original chart.
shape.Delete();

// Now add your own back where old one was.
Shape tmpShape(shapes.AddOLEObject(cLeft, cTop, cWidth, cHeight,
"MSGraph.Chart", "", 0, "", 0, "", 0));
}

// Add another slide, with an Organization chart.
_Slide slide3(slideSet.Add(3, 7));

// Add text to slide as before.
{

Shapes shapes(slide3.GetShapes());
Shape shape(shapes.Item(COleVariant((long)1)));
TextFrame textFrame(shape.GetTextFrame());
TextRange textRange(textFrame.GetTextRange());
textRange.SetText("The rest is only limited by your Imagination");
}
// Add a chart where the default one was created.
{
// First get coordinates of old chart.
float cTop, cWidth, cHeight, cLeft;
Shapes shapes(slide3.GetShapes());
Shape shape(shapes.Item(COleVariant((long)2)));
cTop = shape.GetTop();
cWidth = shape.GetWidth();
cHeight = shape.GetHeight();
cLeft = shape.GetLeft();

// Delete original chart.
shape.Delete();

// Now add your own back where old one was.
// The next line assumes you have the Microsoft OrgChart application
// installed and registered on your computer.
Shape tmpShape(shapes.AddOLEObject(cLeft, cTop, cWidth, cHeight,
"OrgPlusWOPX.4", "", 0, "", 0, "", 0));
}

// Setup slide show properties.
for(int i=1; i<=3; i++) {
_Slide slide(slideSet.Item(COleVariant((long)i)));
SlideShowTransition sst(slide.GetSlideShowTransition());
sst.SetEntryEffect(513); // Random.
sst.SetAdvanceOnTime(TRUE);
sst.SetAdvanceTime(5.0); // 5-seconds per slide.
}
// Prepare and run a slide show.
{
SlideShowSettings sss(pres.GetSlideShowSettings());
sss.SetShowType(3); // Kiosk.
sss.SetLoopUntilStopped(TRUE);
sss.SetRangeType(1); // Show all.
sss.SetAdvanceMode(2); // Use slide timings.
SlideShowWindow ssw(sss.Run()); // Run show.
}

// Sleep so user can watch slide show.
::Sleep(15000);

// Tell PowerPoint to quit.
app.Quit();

7. Add the following lines just before the implementing your button handler:#include "msppt8.h" //msppt9.h for PowerPoint 2000, msppt.h for PowerPoint 2002 and PowerPoint 2003

// Ole initialization class.
class OleInitClass {
public:
OleInitClass() {
OleInitialize(NULL);
}
~OleInitClass() {
OleUninitialize();
}
};
// This global class calls OleInitialize() at
// application startup, and calls OleUninitialize()
// at application exit.
OleInitClass g_OleInitClass;

8. Compile and run.


为什么我用VC控制powerpoint 总是不成功啊?
手头没有头文件,不知道为什么,不过这儿有另一篇,看看是不是你office版本问题:This article was previously published under Q222960 SUMMARY This article describes how to automate Microsoft PowerPoint by using Visual C++ 5.0 or Visual C++ 6.0 with The Microsoft Foundation Classes (MFC).MOR...

在VC中用DSOFRAMER控制PPT进行放映,大家来帮我看看这段代码有什么问题...
lpDispatch = pre.GetSlideShowSettings() ;hr=lpDispatch->QueryInterface(IID_IDispatch,(LPVOID *)&slideShowSettings);这个错了,直接就是:slideShowSettings = pre.GetSlideShowSettings() ;

VC与西门子plc通信的教程
第二种是采用西门子的sapi接口函数,这样plc里面不需要过多的编程了,当然pc侧的编程难度就比较高了,ms只能用c来写,所以我望而却步鸟。初学者可以结合plc视频教程来学习,技成plc不错。

如何用VC编写代码控制打印纸张的大小?
else{ memcpy((void *)&pinfo2,buf,sizeof(pinfo2));pinfo2.pDevMode->dmPaperWidth = PaperWidth;pinfo2.pDevMode->dmPaperLength = PaperLength;pinfo2.pDevMode->dmOrientation = Orientation;} SetPrinter(Printer,2,(unsigned char *)&pinfo2,NULL);Errno=:...

用vc上位机控制51单片机的led灯亮灭,求大神指导如何实现
下面是单片机上的程序,我主要来控制单片机电机和LED的 include<reg52.h> include<reg52.h> include <string.h> sbit led_send=P1^6;sbit led_rec=P1^7;sbit led_working=P1^4;sbit led_ready=P1^2;sbit led_close=P1^0;sbit led_1=P1^1;sbit led_2=P1^3;sbit led_3=P1^5;unsigne...

vc p是什么意思?
它是一个Microsoft旗下的编程软件,可以帮助程序员快速地创建、测试、调试、发布Windows平台上的应用程序。其中,VC P主要面向的是专业级开发人员,提供了丰富的工具和功能,如强大的调试器、多线程和多平台支持、各种库等等。总之,VC P的存在让Windows平台的应用程序开发变得更为高效、便捷。VC P的强大...

急急急!!鄙人学习c语言请教大家vc编辑器怎么用的啊,急!
1.新建一个文本文档,把后缀名改为.cpp,然后双击就可以用VC编辑了。2.调试时:设置断点F9,单步运行F10 快捷键如下 F1: 帮助 Ctrl+O :Open Ctrl+P :Print Ctrl+N :New Ctrl+Shift+F2 :清除所有书签 F2 :上一个书签 Shift+F2 :上一个书签 Alt+F2 :编辑书签 Ctrl+F2 :...

怎样才能用VC的onpaint函数在位图上画点和线呢?就是画完之后能改变位图...
BITMAP bmp;PBITMAPINFO pbmi;WORD cClrBits;\/\/ Retrieve the bitmap color format, width, and height.if (!GetObject(hBmp, sizeof(BITMAP), (LPSTR)&bmp))errhandler("GetObject", hwnd);\/\/ Convert the color format to a count of bits.cClrBits = (WORD)(bmp.bmPlanes * bmp....

VC++命令行操作
CL.exe 是控制 Microsoft C 和 C++ 编译器与链接器的 32 位工具。编译器产生通用对象文件格式 (COFF) 对象 (.obj) 文件。链接器产生可执行文件 (.exe) 或动态链接库文件 (DLL)。注意,所有编译器选项都区分大小写。若要编译但不链接,请使用 \/c。使用 NMAKE 生成输出文件。使用 BSCMAKE 支持类...

VC,PE和天使投资是什么意思?有什么区别?
1.VC,风险投资(英语:Venture Capital)简称风投,又译称为创业投资。主要是指向初创企业提供资金支持并取得该公司股份的一种融资方式。风险投资是私人股权投资的一种形式。风险投资公司为一专业的投资公司,由一群具有科技及财务相关知识与经验的人所组合而成的,经由直接投资获取投资公司股权的方式,提供...

砚山县18422544776: 演示幻灯很别扭,怎么处理?演示时出现提示:microsofto
称单接骨: 你把OFFICE的安装盘再放一次进去,系统会自动装的.放心,装完就好了.

砚山县18422544776: 宝宝上火有哪三大常见症状?
称单接骨: 怎样知道宝宝“上火“了呢?主要有以下三个症状,妈妈一定要注意:“吃不进“孩子不肯吃饭,烦燥不安,甚至不愿进水,诉说口腔疼痛;起病时有发烧,多数为高烧,在口腔内可见单个或成簇的小疱疹,周围有红晕,破溃后易形成溃疡,有黄白色纤维素分泌物覆盖.口唇、舌及颊黏膜均可见到大小不等的疱疹和糜烂或溃疡;“受不了“孩子胃肠功能紊乱,诉说腹部饱胀不适,或腹痛、呕吐、腹泻等症状; “拉不出“孩子大便秘结,每隔3~7天排便一次.大便硬结而量少,呈粟粒状,排便过程延长或排便困难;宝宝眼屎多,头面部长红色疹子.

砚山县18422544776: 如何做课件做课件时,如何将fiash中的动画引入powerpoi
称单接骨: 《中国电脑教育报》以前刊登过在PowerPoint中插入Flash动画的文章,基本方法是... Flash动画会自动播放,不能自主地控制. 近日,我发现在PowerPoint中插入Flash动...

砚山县18422544776: 从邮箱里下载的ppt文件,用wps打开时显示wps再打开文件时?
称单接骨: 请问你安装的是XP还是WIN7系统? 如果是xp,请依次进入“我的电脑”-----“工具... 假如是win7,请依次进入“控制面板”---“程序”---“默认程序”-----“将文件类型或...

砚山县18422544776: 网络PowerPoint如何下载在网络上打开一个Powerpoi
称单接骨: 在下载的地址上右键,目标另存为.

砚山县18422544776: 产后三个月来了例假之后才十多天又来了,请问是怎么回事?
称单接骨: 你好,你的情况不是例假,是恶露,恶露多会反反复复,你可以口服益母草颗粒.

砚山县18422544776: 设置上面那个❶在不更新iOS7的前提下怎么取消感觉有点强迫症?哪
称单接骨: 点进去 看里面是不是有更新 点一下 然后退出来 不更新就可以了 如果我的答案对你有用,麻烦点击"好评",谢谢!

砚山县18422544776: 孕晚期差十几天到预产期了突然肋叉子疼的厉害是怎么回事?这属正常吗?
称单接骨: 正常的,那是快生的现象.亲要注意哟,别走远了,随时待产呀.

砚山县18422544776: 调用服务出错什么意思
称单接骨: 调用服务出错意思就是系统出错,也可能系统在维护或升级.调用服务出错时可以先打开浏览器,按Ctrl、Alt和Del键打开任务管理器,先结束系统杀毒软件,然后再结束explorerexe资源管理器即可.操作系统的主要功能是为管理硬件资源和为应用程序开发人员提供良好的环境来使应用程序具有更好的兼容性,为了达到这个目的,内核提供一系列具备预定功能的多内核函数,通过一组称为系统调用的接口呈现给用户,系统调用把应用程序的请求传给内核,调用相应的内核函数完成所需的处理,将处理结果返回给应用程序.

砚山县18422544776: XP系统,插入u盘不出现发现新硬件的提示,但是能找u盘,问怎么能?
称单接骨: 上面的说法都没说到问题的实质!你的u盘能用,证明系统已经识别出了u盘,即证明bios上没用禁用usb,且系统已经自动赋予盘符,也就不用去再重新指定盘符! 估计你的问题是出在系统在检测到新硬件时的没有提示就直接为其安装驱动并使用了!应该是系统内部出了问题!但并不会对系统造成太大的影响!只是不提示你而已,对于日常使用无大碍!唯一的解决办法是重装系统!不重装也可以,拔u盘的时候这么做: 方法1:鼠标邮件单击u盘的盘符,在右健菜单种选择"弹出"即可. 方法2:在"我的电脑"单击鼠标右键----"计算机管理"---"设备管理"----磁盘驱动器" 选择u盘,然后打开右健菜单---"卸载",即可.

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 星空见康网