Programming PowerPoint with multple object models at once (9.0 and 10.0)

S

Simon Turner

Hi Guys,

Im working on an application to optimise powerpoint files in c#. To
increase its compatilbilty im compiling against the PowerPoint 9.0
Object model to make it compatible with 2000,XP and 2003.

There are differences in the way the 2000 and 2002 object models handle
animation and as im using 2000 when I save the presentation the
animation messes up. It looses things like timing delays or the
ability to start with a previous animation of another shape.

As most people who use my software will have PowerPoint 2002 or above
im considering dropping support to 2000 and compiling against the 2002
object model. As im pretty sure this will fix the problem.

This isn't ideal though, im wondering is there a way to use a newer
object model if it is available in places, like for example animation?
Can multiple object models be used at once? To me is sounds impossible
as a Presentation object from one model could couldn't be equivalent
to another presentation object from a later model, it would never
compile. But I just thought id make sure before I decided to compile
the app to work with the powerpoint 2002 object model(10.0).

Ive been working on this app now for around 9 months and I wouldn't
be anywhere without the help of this group and people taking time out
of there day to help with your problems. Hats off to you all :)

Thank you again.


Simon Turner
 
M

Mike M.

I deal with the same issue Simon and haven't found a viable option within a
single C++ program yet. If you use 2002 specific references then you have
to compile using the 2002 lib. Then if you run the code on a 2000 machine
problems can occur. If you think of something let me know. However, for a
VB program I wrote I needed to be able to support PowerPoint events. Version
2000 and above support that but 97 doesn't. So, I created two dlls. One
uses PPT 97 reference and the other uses 2000. I check the version of PPT
on the machine and use the appropriate dll. That works fine. Maybe that
would work for you.
 
S

Shyam Pillai

I do this all the time with VB/VBA since I always write code to support PPT
97 and later.

The usual approach I use is as follows:
- Write code for the specific versions where incompatible.
- Provide conditional branching based on version using If/Endif/Select Case
/End Case
- Change all declared objects to Object type to prevent compile issues
- Replace all enumerated constants which won't be available in older
versions with the equivalent numeric value in code.
- Compile the code.
 
S

Simon Turner

Hi Guys,

Thanks for the responses :). Just to confirm, this is what ive done....
Ive added a reference to the Object model 10.0 in my project. Im
writing code to handle animation in this for both XP and 2000. Due to
the difference between XP and 2000 ill have to handle both the
Animation Settings object and the TimeLine object. This isnt a problem
and in sure will work fine. Ive used condiational branchin to check
the version number and execute the write code.

However, when i try and run it on PPT 2000 i dont think it creates an
instance of PowerPoint correctly. As when i try and invoke any member
of the application class it fails. This sounds to me like its trying
to look for the 10.0 object library and cant find it. You guys
suggested that i could compile against newer versions and it still
would work on PPT 2000 for example. Have i miss understood?

Thanks once again for your time guys :)

Simon
 
S

Simon Turner

Sorry, last post was slightly incorrect. I can execute some members of
the application class... the following works:

PowerPoint.Presentation myPres =
pptApp.Presentations.Add(MsoTriState.msoFalse);
myPres.Slides.Add(1,PowerPoint.PpSlideLayout.ppLayoutTable);
myPres.SaveAs(@"C:\Sample.ppt",PowerPoint.PpSaveAsFileType.ppSaveAsPresentation,MsoTriState.msoFalse);
myPres.Close();

But if a add this code straight after i get a Object refererence not
set to a ... exception

pptCurrentPres = pptApp.Presentations.Open(@"C:\Sample.ppt",,
MsoTriState.msoFalse,MsoTriState.msoFalse, MsoTriState.msoFalse);

The parameters for this function in both models is the same, the only
difference is that MsoTriSate lives in the Office namespace in 2000 and
in the Microsoft.Office.Core namespace in XP. Could this be the
problem?

Simon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top