PDA

View Full Version : Solved: PP2007/10 Tables



Paul_Hossler
09-16-2011, 08:19 PM
I have to be making this harder than it is

I just want to do some table formatting in slide edit mode

I cannot figure out how to file a cell or how to get to the font formatting

(this is a 2 parter)


Option Explicit
Sub test()
Dim oPres As Presentation
Dim oSlide As Slide
Dim oShape As Shape
Dim oTable As Table
Dim i As Long

Set oPres = ActivePresentation
If oPres Is Nothing Then Exit Sub

Set oSlide = CurrentSlide
If oSlide Is Nothing Then Exit Sub
For Each oShape In oSlide.Shapes
If oShape.HasTable Then
Set oTable = oShape.Table

'idea here is to fill the cells in row 1 with a color, but it doesn't seem to work
For i = 1 To oTable.Columns.Count
With oTable.Cell(1, i).Shape.Fill
.BackColor.RGB = RGB(255, 0, 0)
.BackColor.SchemeColor = ppFill
.Visible = msoTrue
End With
Next i


Stop
End If
Next
End Sub
Function CurrentSlide() As Slide
Dim iCurrentView As Long
Dim iSlide As Long
If ActiveWindow.ViewType = ppViewNormal Then
iSlide = ActiveWindow.View.Slide.SlideIndex
Set CurrentSlide = ActivePresentation.Slides(iSlide)
Else
Set CurrentSlide = Nothing
End If
End Function


I also need to figure out how to make the text in a cell bold, etc.

Help please: pray2:

Paul

Shred Dude
09-18-2011, 03:14 PM
To make the text bold I think this will do it or you...

oTable.Cell(1,1).Shape.TextFrame.TextRange.Font.Bold=msoTrue

As for the back color, I was just playing around with it and haven't stumbled across a way to do it yet either.

Paul_Hossler
09-18-2011, 04:52 PM
Thanks Shred ---

BTW, I'm using PP2010, Vista32


I haven't even gotten that far yet :( :( :( :( :(

So far, in this bit, it seems like .ForeColor and .BackColor are reversed:dunno

If I make FG red and BG black, then it seems to put black text on a red-filled table cell. Maybe I'm misunderstanding FG and BG, or MS is using their own definitions again


With oTable.Cell(1, i).Shape.Fill

End With


Paul

Shred Dude
09-18-2011, 06:16 PM
I'm using PPT 2007 on Win7

This got me a Red Font in a cell with light(er) red shading.

tbl.Cell(2,1).Shape.Fill.ForeColor.RGB=rgb(255,0,0)
tbl.Cell(2,1).Shape.Fill.Transparency=0.75
tbl.Cell(2,1).Shape.TextFrame.TextRange.Font.Color=rgb(255,0,0)

Paul_Hossler
09-18-2011, 06:42 PM
I gotta be not understanding the concepts of FG and BG in PPT

To fill a table row wth black text on a red background, I have to do it in what seems to me to be backwards:

Foreground = red, Background = black


For Each oShape In oSlide.Shapes
If oShape.HasTable Then
Set oTable = oShape.Table

For Each oCell In TableRow(oTable, 1).Cells
With oCell.Shape.Fill
.Solid
.ForeColor.RGB = vbRed
.BackColor.RGB = vbBlack
End With
Next

With TableRow(oTable, 1).Cells
.Borders(ppBorderLeft).ForeColor.RGB = vbRed
.Borders(ppBorderRight).ForeColor.RGB = vbRed
.Borders(ppBorderTop).ForeColor.RGB = vbRed
.Borders(ppBorderTop).Style = msoLineSingle
.Borders(ppBorderTop).Weight = 2

.Borders(ppBorderBottom).ForeColor.RGB = vbBlack
.Borders(ppBorderBottom).Style = msoLineSingle
.Borders(ppBorderBottom).Weight = 2
End With


Stop
End If
Next


Paul

Shred Dude
09-18-2011, 08:38 PM
Playing around this deep into powerpoint is all new to me, so I resorted to the help file. It says the backcolor represents the background color for the specified fill or patterned line. Perhaps that's only relevant when you have a two tone fill format like msoGradientHorizontal? Maybe that backcolor gives you the ability to define what the background color on the two-toned fill pattern would be??


As for controling the color of text in the cell, I think font.color is the way to go.

This gives you a cell with a red background and black text...

tbl.Cell(2,1).Shape.Fill.ForeColor.RGB=vbred
tbl.Cell(2,1).Shape.TextFrame.TextRange.Font.Color=vbblack

Paul_Hossler
09-19-2011, 05:13 AM
Perhaps that's only relevant when you have a two tone fill format like msoGradientHorizontal? Maybe that backcolor gives you the ability to define what the background color on the two-toned fill pattern would be

Perhaps. That seems to be the net effect, but ... boy is that a help topic that is beggining for more examples

Paul

John Wilson
09-23-2011, 07:38 AM
I guess you worked this out:
Forecolor is used in most normal uses (eg Fill) I think of it as Color1. Backcolor is used only if you have two color gradients / patterns.

Paul_Hossler
09-23-2011, 03:28 PM
John & Shred




PowerPoint Developer Reference

FillFormat.BackColor PropertyReturns or sets a ColorFormat (http://www.vbaexpress.com/forum/ms-help://MS.POWERPNT.DEV.14.1033/POWERPNT.DEV/content/HV10309814.htm) object that represents the background color for the specified fill or patterned line. Read/write.

FillFormat.ForeColor Property
Returns or sets a ColorFormat (http://www.vbaexpress.com/forum/ms-help://MS.POWERPNT.DEV.14.1033/POWERPNT.DEV/content/HV10309814.htm) object that represents the foreground color for the fill, line, or shadow. Read/write.


Oh, sure .. it's easy once a couple of pros explain it to you :yes (twice)

I guess I was getting confused since on a Userform, .BackColor and .ForeColor for a control are the fill and the font respectively.

Thanks again

Paul

PS I still think the Help could be improved