Strange PowerPoint Automation interface failure

Tech-Archive recommends: Speed Up your PC by fixing your registry



VS.NET 2003, talking to PPT 2003

When I open some presentations, using presentations.Open, everything works fine, but in
other presentations, it throws a COleException whose code is 'Type mismatch'. The call is

presentations.Open(filename, 0, 0, 1)

Specifically, the code is

try { /* try */
CPresentations presentations; // From CPresentations.h, the presentations coll.
CPresentation presentation; // From CPresentation.h

CString uname = filename;
uname.MakeUpper(); // convert ot all-uppercase

HERE(); // part of my debugging support, records line# for error report
presentations = app.get_Presentations(); // works fine

HERE();
int PresentationsCount = presentations.get_Count(); // # of presentations

// See if the presentation is already open; if so, just connect to it,
// don't open it a second time

for(int i = 1; i <= PresentationsCount; i++)
{ /* scan presentations */
HERE();
presentation = presentations.Item(COleVariant((long)i));
HERE();
CString pname = presentation.get_FullName();
pname.MakeUpper();
if(uname == pname)
{ /* found presentation */
TRACE(_T("PowerPointManager::OpenPresentation Found [%d] \"%s\"\n"), i,
filename);
FileSet::SetPresentation(fid, presentation);
FileSet::SetAlreadyOpen(fid, TRUE);
return TRUE;
} /* found presentation */
} /* scan presentations */

TRACE(_T("PowerPointManager::OpenPresentation Opening \"%s\"\n"), filename);
HERE();
presentation = presentations.Open(filename,
0, // ReadOnly
0, // Untitled
1); // WithWindow
//******************** Throws exception ***********************8

if(presentation == NULL)
return FALSE;
return FileSet::SetPresentation(fid, presentation);
} /* try find */
catch(COleException * e)
{ /* find failed */
HandleOleException(e, fid, 0, where, NULL);
return FALSE;
} /* find failed */
============================================

There are two problems here. One is that many other presentations have been opened
already from this call, and if I proceed from the call, many other presentations will be
opened by this call (the processing opens eight presentations, but only two of them report
"type mismatch". The second one is that in the debug build, it throws the exception, I
catch it in the catch clause, and all is sort-of-good. But in the Release build, the
lower-level code terminates the execution, which doesn't make any sense. It doesn't let
the exception get back to me.

So: what does 'type mismatch' mean? (my HandleOleException function prints out the
FormatMessage of the m_sc code of the COleException). How do I avoid it? And how do I
make sure that I get all the exceptions, without, shall we say, exception?

[I've already posted this on the microsoft.public.office.developer.automation newsgroup]

joe
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.



Relevant Pages

  • Type mismatch from MFC automation interface
    ... it throws a COleException whose code is 'Type mismatch'. ... opened by this call (the processing opens eight presentations, but only two of them report ... The second one is that in the debug build, it throws the exception, I ... FormatMessage of the m_sc code of the COleException). ...
    (microsoft.public.office.developer.automation)
  • Re: Evaluating Exceptions, Try Except and Try Finally
    ... work with the resource ... Consider your database example. ... exception handling differently than if the db open is something optional. ... both cases the code that actually opens the db shouldn't be the one making ...
    (alt.comp.lang.borland-delphi)
  • Re: type inference problem in my ocaml program (program is very short)
    ... I always try to explain any shortcomings of code (the shortcomins that ... it opens the door for further questions on the part of the person who ... There is an exception, however. ... would leak resources in some exceptional situations. ...
    (comp.lang.functional)
  • Re: Visual Studio Crashes Opening an Orchestration
    ... This happens when I open any orchestration. ... clicking on an orchestration opens the file in a new instance of VS fine. ... I can use every other file type except the orchestrations. ... Unhandled exception at 0xc5b917e3 in devenv.exe: 0xC0000005: Access ...
    (microsoft.public.biztalk.general)
  • Re: Evaluating Exceptions, Try Except and Try Finally
    ... ofcourse not true if an exception happens before the try block is entered! ... SINCE THE CONNECTION DID NOT OPEN ???!!!?? ... Opens a database connection with the settings specified by the ... Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows ...
    (alt.comp.lang.borland-delphi)