Visual c++ COM automation for powerpoint

M

matthew.d.trepina

I am developing a Visual C++ MFC app that creates a powerpoint slide.
I am having a problem chaning the color of the font in my text box and
closing the powerpoint instance after I close the dispatch I created.
When I looked at the generated c + h files for msppt9.olb the dispatch
ID for color changing under RBGColor and ColorFormat is 000000000. I
think this is a problem. Any suggestions.
 
M

Mike M.

See example below your post:

I am developing a Visual C++ MFC app that creates a powerpoint slide.
I am having a problem chaning the color of the font in my text box and
closing the powerpoint instance after I close the dispatch I created.
When I looked at the generated c + h files for msppt9.olb the dispatch
ID for color changing under RBGColor and ColorFormat is 000000000. I
think this is a problem. Any suggestions.

Excerpt from some code I use:

void :putText(CString& text, PowerPoint::TextRangePtr &range)
{
CString m_fontFace;
double m_size;
COLORREF m_color;
BOOL m_fBold;
BOOL m_fItalic;
BOOL m_fUnderline;

m_color = RGB(0, 0, 0);
m_fBold = false;
m_fItalic = false;
m_fontFace = "Arial";
m_fUnderline = false;
m_justify = center;
m_size = 12.0;

range->PutText(_bstr_t(text));
PowerPoint::FontPtr aFont = range->Font;
aFont->PutName(_bstr_t(m_fontFace));
aFont->PutSize(m_size);
aFont->PutBold(m_fBold ? Office::msoTrue : Office::msoFalse);
aFont->PutItalic(m_fItalic ? Office::msoTrue : Office::msoFalse);
aFont->PutUnderline(m_fUnderline ? Office::msoTrue : Office::msoFalse);
aFont->PutEmboss(Office::msoFalse);
aFont->PutShadow(Office::msoFalse);
aFont->PutSubscript(Office::msoFalse);
aFont->PutSuperscript(Office::msoFalse);

PowerPoint::ColorFormatPtr aColor = aFont->Color;
aColor->PutRGB(m_color);

}
 
M

matthew.d.trepina

This is what I have COLORREF m_color = RGB(255,255,255);
Font font = text_range.GetFont();
font.SetName("Comic Sans MS"); //Set the font name.
font.SetSize((float)48); //Set the font size.
ColorFormat color_format(font.GetColor());
color_format.SetRgb(m_color);

how did you get PowerPoint::ColorFormat / PtrPowerPoint::FontPtr
I don't have those types of options can you place more of your source
code
 
M

Mike M.

I import the PowerPoint and Office type libraries in stdafx.cpp and
stdafx.h, either for 2000 or 2002.
stdafx.cpp
// 2000
#import <msppt9.olb> implementation_only
#import <mso9.dll> implementation_only
// 2002
#import <msppt.olb> implementation_only
#import <mso.dll> implementation_only
stdafx.h
// 2000
#import <msppt9.olb> no_implementation
#import <mso9.dll> no_implementation
// 2002
#import <msppt.olb> no_implementation
#import <mso.dll> no_implementation


That gives me the files mso.tlh, mso.tli, msppt.tlh and msppt.tlh where all
the classes and methods are defined. Some of the methods are from the
Office object model and some are from PowerPoint.

HTH
 

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