本人想通过VC调用PowerPoint的接口来操作PPT文档,一切都好,可就是解析的时候调用open函数,会弹出PowerPoint的窗口,再然后将窗口隐藏
_Application *g_app = NULL;
_Presentation *g_pPresentation;
Presentations *pPresentations = NULL;
Slides *g_pSlides;
HRESULT
hr;
// COM环境初始化
hr = CoInitialize(NULL);
if
(FAILED(hr))
{
return
;
}
// 创建Application类,返回_Application接口
hr = CoCreateInstance(__uuidof(PowerPoint::Application),
NULL,
CLSCTX_LOCAL_SERVER,
__uuidof(PowerPoint::_Application),
(
LPVOID
*)&g_app);
g_app->put_Visible(msoTrue);
// 显示Powerpoint窗口
// 此处如果不让PowerPoint窗口弹出,后面的操作都没法进行
g_app->put_WindowState(ppWindowMinimized);
// 窗口最小化
g_app->get_Presentations(&pPresentations);
// 获取Presentaions类
//打开PPT文件,返回_Presentation接口
pPresentations->Open(_bstr_t(pptPath), msoFalse, msoFalse, msoTrue, &g_pPresentation);
g_pPresentation->get_Slides(&g_pSlides);
// 获取Slides
long
count = 0;
g_pSlides->get_Count(&count);
// 遍历每张Slide
g_app->put_Visible(msoTrue); // 显示Powerpoint窗口
// 此处如果不让PowerPoint窗口弹出,后面的操作都没法进行
我不知道为什么会这样,我觉得弹出来很不爽,我见过有些PPT处理软件,也打开了PowerPoint的进程,但是没见到窗口弹出,不知道是如何实现的,望各位大侠帮忙啊!感激不尽!如果有解决方案,本人再加200分
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
我都试过了,没问题的。
这这两句删除。
g_app->put_Visible(msoTrue);
g_app->put_WindowState(ppWindowMinimized);
只需要Open的第四个参数设置为msoFalse。
pPresentations->Open(_bstr_t(pptPath), msoFalse, msoFalse,msoFalse, &g_pPresentation);