DBS
DBS

Reputation: 301

Powerpoint table size from Matlab

I want to fill in a powerpoint (I'm working on 2007) table with data from Matlab (2010a).

For that, I'm using inside MATLAB:

% Open powerpoint with handle
ppH = actxserver('PowerPoint.Application');

% Add new presentation
presH = ppH.Presentation.Add;

% Add blank slide
blankSlide = presH.SlideMaster.CustomLayouts.Item(7);
slideH = presH.Slides.AddSlide(1,blankSlide);

% Create 10x5 table
tableH = slideH.Shapes.AddTable(10,5,10,10,200,200);

Ok so, now I want to change cell's height and width. I've tried so far with no success:

tableH.Table.Cell(1,1).Shape.Width = 95;
tableH.Table.Columns(1).Shape.Width = 95;
tableH.Table.Columns(1).Width = 95;
tableH.Table.Cell(1,1).Parent.Columns(1).Width = 95;
slideH.Shapes(1).Table.Columns(1).Width = 95;

Do you know how to do this?

DBS.

Upvotes: 1

Views: 2135

Answers (2)

DBS
DBS

Reputation: 301

I got it running with:

tableH.Table.Columns.Item(1).Width = 95;

Where Item(i) denotes the ith column.

Thanks for the help!

Upvotes: 0

Steve Rindsberg
Steve Rindsberg

Reputation: 14809

This works in PPT 2010 where the table OM is semi-broken. Whether it'll work in PPT 2007 where the table OM is a trainwreck is another story. If it doesn't set the first column of the currently selected table to two inches (144points) wide, it's likely due to PPT bugginess.

Dim osh As Shape
Dim oTbl As Table
Set osh = ActiveWindow.Selection.ShapeRange(1)
Set oTbl = osh.Table

With oTbl
    .Columns(1).Width = 144
End With

Upvotes: 1

Related Questions