MSDN Example for PowerPoint Automation fails to work

S

scott.schmerer

Hello all

I based a new project on the info found here:
http://support.microsoft.com/kb/q169505/

I have these three imports in all of my wrapper classes:

#import "C:\\Program Files\\Common Files\Microsoft Shared\\OFFICE11\
\MSO.DLL" \
named_guids, \
rename("RGB", "MsoRGB")

// The following #import is necessary for MS Office without
raw_interfaces_only.. It defines VBEPtr among other things.
#import "C:\\Program Files\\Common Files\\Microsoft Shared\\VBA\\VBA6\
\VBE6EXT.OLB" raw_interfaces_only

// Import PPT's interfaces.
#import "C:\\Program Files\\Microsoft Office\\OFFICE11\\MSPPT.OLB" \
rename("ExitWindows", "MsoExitWindows"), \
rename("FindText", "MsoFindText")


I went through and created the different menu handlers like the
example tells you to. But in the menu handler to Create a
Presentation this error is thrown:
error C2039: 'Add' : is not a member of 'CPresentations'

Inside of CPresentations no Add function was created during the Class
Creation Wizard, so I don't see how the example code could have worked
when MSDN put it up.

Has anyone been able to automate creation of presentation and slides
in PowerPoint?

I am using VS2005 and PowerPoint 2003.

Here is the function from the example, slightly tweaked since the
class creation added the "C" to the Presentation class, and the
example didn't use it that way:

void CMainFrame::OnPowerpointCreatepresentation()
{
CPresentations PresCollection;

// Make sure there is a dispatch pointer for PowerPoint.
if(m_ppt.m_lpDispatch == NULL) {

// Display a message indicating that PowerPoint is not running.
MessageBox(_T("PowerPoint is not running. Start PowerPoint"));
} else {

// Bring PowerPoint to the front.
m_ppt.Activate();

// Attach the presentations collection to the PresCollection
// variable.
PresCollection.AttachDispatch(m_ppt.get_Presentations());

PresCollection.Add(1);
}
}
 

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