Click here to Skip to main content
15,886,673 members
Home / Discussions / COM
   

COM

 
QuestionHow to catch ActiveX Install or Excute using BHO? Pin
Blue-Bird23-Feb-06 19:00
Blue-Bird23-Feb-06 19:00 
QuestionError In Building simple ATL application Pin
maharaja pandian23-Feb-06 1:49
maharaja pandian23-Feb-06 1:49 
AnswerRe: Error In Building simple ATL application Pin
toxcct23-Feb-06 2:13
toxcct23-Feb-06 2:13 
AnswerRe: Error In Building simple ATL application Pin
Stephen Hewitt23-Feb-06 19:20
Stephen Hewitt23-Feb-06 19:20 
QuestionCOM Server in VB Pin
Anil_vvs23-Feb-06 0:01
Anil_vvs23-Feb-06 0:01 
AnswerRe: COM Server in VB Pin
Anil_vvs23-Feb-06 0:05
Anil_vvs23-Feb-06 0:05 
AnswerRe: COM Server in VB Pin
Lim Bio Liong24-Feb-06 23:38
Lim Bio Liong24-Feb-06 23:38 
QuestionGet serious trouble in Powerpoint automation code Pin
Zhaohui Xing (Joey)22-Feb-06 16:30
Zhaohui Xing (Joey)22-Feb-06 16:30 
I create a C++ Powerpoint automation test program following the MSDN article "
How to create an automation project using MFC and a type library" steps.
But get serious trouble when it parses only a single rectange shape in a simple single PPT slide

The proble is always get assertion in "pptApp.put_Visible(false);"
"long nCount = shapepts.get_Count(); "
" long n = gshapes.get_Count(); "

Also I get assertion if I call shape.get_Vertice()

I ugently need the help to solve this problem.

the code is:

#include "stdafx.h"
#include "testPPT.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif

#include <afxdisp.h>

#include "CPresentation.h"
#include "CApplication.h"
#include "CShapeNode.h"
#include "CSlides.h"
#include "CShapeNodes.h"

#include "CDocumentWindow.h"
#include "CPresentations.h"
#include "CShapes.h"
#include "CPageSetup.h"

#include "CFreeformBuilder.h"
#include "CPictureFormat.h"
#include "CShapeRange.h"
#include "CColorScheme.h"
#include "CMaster.h"
#include "CDesign.h"
#include "CHyperlinks.h"
#include "CActionSetting.h"
#include "CTextFrame.h"
#include "CSlide.h"
#include "CShape.h"
#include "CGroupShapes.h"

#include "CColorFormat.h"

#ifndef POWERPOINT_NOTINSTALLED
#define POWERPOINT_NOTINSTALLED 0
#endif

#ifndef POWERPOINT95
#define POWERPOINT95 1
#endif

#ifndef POWERPOINT97
#define POWERPOINT97 2
#endif

#ifndef POWERPOINT2000
#define POWERPOINT2000 3
#endif

#ifndef POWERPOINT2002
#define POWERPOINT2002 4
#endif

#ifndef POWERPOINT2003
#define POWERPOINT2003 5
#endif

//??????????????????????????????
//The Powerpoint conversion error code -- 2006-02-16, zxing
#define PPTCONV_OK 0 //OK
#define PPTCONV_NOPPT 1 //No Powerpoint installed
#define PPTCONV_NOPPTFILE 2 //No Powerpoint file
#define PPTCONV_PPTNOTRUN 3 //Cannot run powerpoint
#define PPTCONV_WRONGPPTVER 4 //Wrong Powerpoint version
//??????????????????????????????

// The one and only application object

CWinApp theApp;

using namespace std;

const OLECHAR FAR* szPPTProgID[] =
{
OLESTR("PowerPoint.Application.7"), // PowerPoint 95
OLESTR("PowerPoint.Application.8"), // PowerPoint 97
OLESTR("PowerPoint.Application.9"), // powerPoint 2000
OLESTR("PowerPoint.Application.10"), // powerPoint 2002
OLESTR("PowerPoint.Application.11"), // powerPoint 2003
};

long QueryPPTVersion(void)
{
long nRet = POWERPOINT_NOTINSTALLED;

CLSID clsid;
for (long i = POWERPOINT95; i <= POWERPOINT2003; i++ )
{
//Query class ID from system
if (SUCCEEDED(CLSIDFromProgID(szPPTProgID[i-1], &clsid)))
{
return i;
}
}
return nRet;
}

bool PPTStartup(CApplication& pptApp, long nVer, bool bShow, long& nPrevWS)
{
bool bRet = false;

if(nVer < POWERPOINT95 || POWERPOINT2003 < nVer)
{
return bRet;
}

CLSID clsid;

if(!SUCCEEDED(CLSIDFromProgID(szPPTProgID[nVer-1], &clsid)))
{
return false;
}

if(!pptApp.CreateDispatch(clsid))
{
TRACE(_T("Couldn't start PowerPoint and get Application object."));
return bRet;
}

nPrevWS = pptApp.get_WindowState();

if(bShow)
{
pptApp.put_Visible(true);
}
else
{
pptApp.put_Visible(false); //Failed get assertion
}

bRet = true;
return bRet;
}


int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;

// initialize MFC and print and error on failure
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
// TODO: change error code to suit your needs
_tprintf(_T("Fatal Error: MFC initialization failed\n"));
nRetCode = 1;
}
else
{
// TODO: code your application's behavior here.
}

nRetCode = OleInitialize(NULL);

long nVer = QueryPPTVersion();
long nPrevWS;
bool bShow;

CApplication pptApp;

if(!PPTStartup(pptApp, nVer, true, nPrevWS))
{
ASSERT(FALSE);
}

CPresentations pptPresentations = pptApp.get_Presentations() ;

CPresentation pptPresentation;
pptPresentation = pptPresentations.Open(_T("C:\\Dev\\outline.ppt"), FALSE, TRUE, TRUE);


CSlides pptSlides;
pptSlides = pptPresentation.get_Slides();
CSlide crtSlide;
crtSlide = pptSlides.Item(COleVariant((long)1));

CShapes shapes = crtSlide.get_Shapes();
CShape shape;
shape = shapes.Item(COleVariant((long)1));

CShapeNodes shapepts = shape.get_Nodes();

long nCount = shapepts.get_Count(); //Get Assertion

CGroupShapes gshapes = shape.get_GroupItems();

long n = gshapes.get_Count(); //Get Assertion

if(pptPresentation.m_lpDispatch != NULL)
{
pptPresentation.Close();
pptPresentation.ReleaseDispatch();
pptPresentation.m_lpDispatch = NULL;
}

if(pptApp.m_lpDispatch != NULL)
{
pptApp.Quit();
pptApp.ReleaseDispatch();
pptApp.m_lpDispatch = NULL;
}

return nRetCode;
}
QuestionHow to correctly use CoInitialize? Pin
Waldermort22-Feb-06 3:34
Waldermort22-Feb-06 3:34 
AnswerRe: How to correctly use CoInitialize? Pin
Milton Karimbekallil22-Feb-06 5:42
Milton Karimbekallil22-Feb-06 5:42 
GeneralRe: How to correctly use CoInitialize? Pin
Waldermort22-Feb-06 15:19
Waldermort22-Feb-06 15:19 
GeneralRe: How to correctly use CoInitialize? Pin
User 21559722-Feb-06 21:51
User 21559722-Feb-06 21:51 
GeneralRe: How to correctly use CoInitialize? Pin
Rory Solley22-Feb-06 21:58
Rory Solley22-Feb-06 21:58 
GeneralRe: How to correctly use CoInitialize? Pin
Waldermort23-Feb-06 1:37
Waldermort23-Feb-06 1:37 
GeneralRe: How to correctly use CoInitialize? Pin
Waldermort23-Feb-06 1:41
Waldermort23-Feb-06 1:41 
QuestionPassing interface as parameters of functions Pin
nripun21-Feb-06 23:51
nripun21-Feb-06 23:51 
AnswerRe: Passing interface as parameters of functions Pin
Malli_12322-Feb-06 0:03
Malli_12322-Feb-06 0:03 
GeneralRe: Passing interface as parameters of functions Pin
nripun22-Feb-06 1:02
nripun22-Feb-06 1:02 
Questionhow to get the selected files name during Drag&Drop's mouse moving process Pin
welli21-Feb-06 21:28
welli21-Feb-06 21:28 
QuestionIE Toolbar (Toolband) Pin
vaughandaly21-Feb-06 20:49
vaughandaly21-Feb-06 20:49 
QuestionIDispatch and bookmarks in word Pin
lparsonson21-Feb-06 4:37
lparsonson21-Feb-06 4:37 
QuestionConnecting to a running IE COM instances. Pin
TClarke21-Feb-06 3:42
TClarke21-Feb-06 3:42 
QuestionAccess violation in ADODB::Connection Pin
Dyrl20-Feb-06 7:13
Dyrl20-Feb-06 7:13 
AnswerRe: Access violation in ADODB::Connection Pin
lparsonson21-Feb-06 4:35
lparsonson21-Feb-06 4:35 
GeneralRe: Access violation in ADODB::Connection Pin
Dyrl21-Feb-06 8:48
Dyrl21-Feb-06 8:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.