How to change font size for a table

F

Fred

Hi everybody,

I counldn't find an answer to my question: how to change the font
attributes (e.g. size) for a whole table in an original powerpoint
table.

Once I have created the table through
ActiveWindow.Selection.SlideRange.Shapes.AddTable(4, 4).Select

I store the object ID (e.g. "Group 3020")
ReDim Preserve tblName(1 To 1)
tblName(1) = ActiveWindow.Selection.ShapeRange.Name
Set oShape = ActiveWindow.Selection.SlideRange.Shapes(tblName(1))

But when I try to address the objects' font attribute through
ActiveWindow.Selection.SlideRange.Shapes(oShape.Name).Select
With ActiveWindow.Selection.ShapeRange.TextFrame.TextRange
.Font.Name = "Courier"
.Font.Size = 12
.Font.Bold = msoTrue
End With
It gives the following error message: "TextFrame(unknown member): This
type of shape cannot have a textrange"

Since I can (on an slide) simply select a powerpoint table and change
the font attributes for the whole table at once, I wonder how to perfom
this in vba (should be possible - shouldn't it?)

Best regards to good ideas

Fred
 
S

Shyam Pillai

Fred,

Try the following:

Sub SetTableFont()
Dim oShp As Shape
Dim oTbl As Table
Dim I As Long
Dim J As Long

Set oShp = ActiveWindow.Selection.ShapeRange(1)
Set oTbl = oShp.Table

For I = 1 To oTbl.Columns.Count
For J = 1 To oTbl.Rows.Count
oTbl.Cell(I, J).Shape.TextFrame.TextRange.Font.Name = "Verdana"
Next
Next
End Sub


--
Regards,
Shyam Pillai

Animation Carbon
http://www.AnimationCarbon.com
 
F

Fred

Hi guys,

thanks for the input. Since no one came up with a faster method than
scrolling through each and every cell, I used Shyam's technique to set
the font. However, I've encountered a mysterious thing anyways: the
code does not affect the size attribute. Even when I address only the
size with

Sub SetTableFont()
Dim oShp As Shape
Dim oTbl As Table
Dim I As Long
Dim J As Long


Set oShp = ActiveWindow.Selection.ShapeRange(1)
Set oTbl = oShp.Table


For I = 1 To oTbl.Columns.Count
For J = 1 To oTbl.Rows.Count
oTbl.Cell(I, J).Shape.TextFrame.TextRange.Font.Size = 12
Next
Next
End Sub

... then it leaves the table with font size 10, which is really akward.
Would anyone have an idea on this one?

Thanks in advance.
Fred
 
F

Fred

Hi Steve,

thanks for you feedback. However, it for a reason doesn't do what it's
supposed to do. (I work on ppt 2003). I have selected the shape (I
couldn't find a .select for the table). Still doesn't work. Still does
only change the font.type.
By the way: you have mentioned to avoid selecting things when possible.
Why is that?

Best regards
Fred
 
F

Fred

Steve,

thanks for your answer on the selection.
Thanks for your input on the font.size. I somehow tried the
..insertafter.font.size . This works, but only if I insert real text
(e.g. blank or a letter; not with ""). What is wrong in my setting?

Thanks
Fred
 
F

Fred

Steve,
thanks, I knew ppt has some odities in it. But I didn't think I need to
get around it.

Regards,
Fred
 

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