Solved

Format a Cell in a Table Shape in PowerPoint 2007

Posted on 2013-10-22
5
2,340 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 48

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 48

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 48

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
maven archtype selection in eclipse 1 51
sum28 challenge 31 96
no14 challenge 14 56
data scientists and AI 17 69
Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
The purpose of this article is to demonstrate how we can use conditional statements using Python.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …

705 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

13 Experts available now in Live!

Get 1:1 Help Now