Solved

Format a Cell in a Table Shape in PowerPoint 2007

Posted on 2013-10-22
5
2,451 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 50

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 50

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 50

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Slide Show 5 139
Capture logon name 13 106
Linked excel chart in PPT for export to other users 7 89
VBA MsgBox command is dumping object variables? 8 72
Preface: When I started this series, I used the term CommandBars because that is the Office Object class that it discusses. Unfortunately, when Microsoft introduced Office 2007, they replaced the standard Commandbar menus with "The Ribbon" and rem…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

730 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