Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Format a Cell in a Table Shape in PowerPoint 2007

Posted on 2013-10-22
5
Medium Priority
?
2,546 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 52

Accepted Solution

by:
Rgonzo1971 earned 1000 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 52

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 52

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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

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 …
PowerPoint is the go-to presentation software for millions of users around the world. Many presentations use basic text features but you can really make special text jump out of your slide by applying this bubble text design process. This article ha…
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  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