Solved

Format a Cell in a Table Shape in PowerPoint 2007

Posted on 2013-10-22
5
2,367 Views
Last Modified: 2013-12-12
In the absence of PowerPoint 2007 Macro Recorder, how do you format a table cell's background to be Red with White Centered Text with Calibri 8pt Font?  I tried using Word 2007 VBA code but it does not appear to be the same.

CowboyWM
0
Comment
Question by:cowboywm
  • 3
5 Comments
 
LVL 49

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 39597451
i,

pls try

Sub Macro()
Set PPTSlide = ActivePresentation.Slides(1)

Set objTable = PPTSlide.Shapes.AddTable(3, 4, 10, 10, 288, 216)
With objTable.Table.Columns(1).Cells(1).Shape
.Fill.ForeColor.RGB = 255
.TextFrame.TextRange.Font.Color = vbWhite
.TextFrame.TextRange.Font.Name = "Calibri"
.TextFrame.TextRange.Font.Size = 8
.TextFrame.TextRange.ParagraphFormat.Alignment = ppAlignCenter
End With
End Sub

Open in new window

Regards
0
 

Author Comment

by:cowboywm
ID: 39606289
Not looking for a new table to be inserted into the current slide.  I already have a table with 6 columns and 6 rows.  If I position my cursor in any cell, I want the macro to change the background to be Red with White Centered Text with Calibri 8pt Font.
0
 
LVL 49

Expert Comment

by:Rgonzo1971
ID: 39607928
Hi,

pls try
Sub Macro()

With ActiveWindow.Selection
    With .TextRange
        .Font.Color = vbWhite
        .Font.Name = "Calibri"
        .Font.Size = 8
        .ParagraphFormat.Alignment = ppAlignCenter
    End With
    If .ShapeRange(1).Type = msoTable Then
        Set oTbl = .ShapeRange(1).Table
        For x = 1 To oTbl.Columns.Count
            For y = 1 To oTbl.Rows.Count
                If oTbl.Cell(x, y).Selected Then
                    With oTbl.Cell(x, y).Shape
                        .Fill.ForeColor.RGB = 255
                    End With
                End If
            Next
        Next
    End If
End With

End Sub

Open in new window

Regards
0
 
LVL 23

Expert Comment

by:JSRWilson
ID: 39614427
Did you check the code of a non square table?? Say 8 x 3.
0
 
LVL 49

Expert Comment

by:Rgonzo1971
ID: 39616475
Hi

@ JSRWilson  Tks I forgot it is like in Excel : Cell(row, column)

Corrected version
Sub Macro()

With ActiveWindow.Selection
    With .TextRange
        .Font.Color = vbWhite
        .Font.Name = "Calibri"
        .Font.Size = 8
        .ParagraphFormat.Alignment = ppAlignCenter
    End With
    If .ShapeRange(1).Type = msoTable Then
        Set oTbl = .ShapeRange(1).Table
        For x = 1 To oTbl.Columns.Count
            For y = 1 To oTbl.Rows.Count
                If oTbl.Cell(y, x).Selected Then
                    With oTbl.Cell(y, x).Shape
                        .Fill.ForeColor.RGB = 255
                    End With
                End If
            Next
        Next
    End If
End With

End Sub

Open in new window

Regards
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many programs have tried to outwit PowerPoint in terms of technology and skill. These programs, however, still lack several characteristics that PowerPoint has possessed from the start. Here's why PowerPoint replacements won't entirely work for desi…
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now