Discussion:
Visual c++ COM automation for powerpoint
(too old to reply)
m***@gmail.com
2005-10-18 15:40:01 UTC
Permalink
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.
Mike M.
2005-10-18 17:43:22 UTC
Permalink
Post by m***@gmail.com
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***@gmail.com
2005-10-19 16:31:14 UTC
Permalink
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
Mike M.
2005-10-20 13:10:55 UTC
Permalink
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
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
Loading...