Powerpoint table creation (vc++)

R

Rodger Fromm

I am currently integrating powerpoint into an application(using vc++ 6 and
Powerpoint 2002, using the msppt.olb) to auto creat a powerpoint file, i am
having one problem though. I have managed to creat the new file, add text
only slides, add text and picture slides(custome graphs), and i have been
able to create new tables. but i can not figure out how to insert tect into
the cells of the slides.
this is where i am at:
/////
_Slide slide1(SlideSet.Add(Position, 11));
Shapes shapes(slide1.GetShapes());
Shape shape(shapes.Item(COleVariant((long)(1))));
TextFrame textFrame(shape.GetTextFrame());
TextRange textRange(textFrame.GetTextRange());
textRange.SetText(DataArr.GetAt(0));//DataArr is my CStringArray

Shape shape2(shapes.AddTable(8,4,100,100,550,400));
Table grid(shape2.GetTable());
....
This is where my problem is. the table creates, but i have been trying to
do everything to get text into the cells of the table, but i can not figure
it out.
Oh how i wish the cell had a set text function

Any help would be more then apreciated, even if it is a recomendation of a
book
 
S

Steve Rindsberg

A crude quick shot at it in VBA:

Dim x as Long
Dim y as long
Dim oSh as Table

' Get a reference to the currently selected table
' You'll want to do this differently of course
Set oSh=ActiveWindow.Selection.ShapeRange(1).Table

For x = 1 to oSh.Rows.Count
For y = 1 to oSh.Columns.Count
oSh.Cell(x,y).Shape.TextFrame.TextRange.Text = "HI!"
Next
Next
 
R

Rodger Fromm

Well strangly, something clicked when i read that, though in vc++ it has to
be done a more insane way, but from this, i did figure out what i needed. I
had to do it this way:
Shape shape2(shapes.AddTable(3,3,100,100,550,400));
Table grid(shape2.GetTable());
for (i=1; i<4;i++)
{
for (j=1;j<4;j++)
{
Cell mycell(grid.Cell(i,j));
Shape shape3(mycell.GetShape());
TextFrame textFrame2(shape3.GetTextFrame());
TextRange textRange2(textFrame2.GetTextRange());
textRange2.SetText(DataArr.GetAt(count));
count++;
}
}

All that just to put data in a cell, oh well, i will only have to write it
once.
thanks again.

Rodger
 
R

Rodger Fromm

Oh it deffinatly runs fast, especially if you do not open up the GUI and just
run in the background, will be seeing how fast it really is next week when i
have an app throw 100 slides worth of data at it and see how long it is till
the file is created.

Rodger Fromm
 

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