PPT.TableBackground in MS PowerPoint 2010 to Set Background Fill in Tables in VB.NET
In this article I am going to explain about how to Set Background Fill in Tables in a Microsoft PowerPoint 2010 presentation.
Introduction
In this article I am going to explain about how to Set Background Fill in Tables in a Microsoft PowerPoint 2010 presentation. For this we use PPT.TableBackground in Microsoft PowerPoint 2010. Using PPT.TableBackground we can set the background fill properties for each cell of a table in a Microsoft PowerPoint 2010 presentation.
Microsoft Office 2010 offer some powerful tools, using this tools you can create application. Using Microsoft Visual Basic for Applications (VBA) you can create your own application according to your need. These application can performer some specific task.
For creating application we can use
- VBA host of Excel 2010
- VBA host of PowerPoint 2010
- VBA host of Word 2010
NOTE : OneNote 2010 is not a VBA host.
Code that we use in this application are given below
Sub WorkWithTableBackground()
Dim vip As Presentation
vip = ActivePresentation
' Create a slide with a table on it:
Dim vip1 As Slide
vip1 = vip.Slides.Add(2, ppLayoutTable)
Dim vip2 As Table
vip2 = vip1.Shapes.AddTable(4, 4).Table
' Fill the table with data:
FillTable(vip2)
' Retrieve Background property:
Dim tb As TableBackground
tb = vip2.Background
' Should be able to do this:
tb.Fill.ForeColor.ObjectThemeColor = msoThemeColorAccent2
' This procedure sets the cell color:
SetTableColor(vip2, msoThemeColorAccent2)
' This procedure sets the cell texture:
SetTableTexture(vip2, msoTextureCork)
End Sub
Sub FillTable(vip2 As Table)
' Fill a table with sample data.
Dim r1 As Integer
Dim c1 As Integer
For c1 = 1 To vip2.Columns.Count
vip2.Cell(1, c1).Shape.TextFrame.TextRange.Text = "Heading " & c1
Next c1
Dim shp As Shape
For r1 = 2 To vip2.Rows.Count
For c1 = 1 To vip2.Columns.Count
shp = vip2.Cell(r1, c1).Shape
shp.TextFrame.TextRange.Text = "Cell " & r1 & ", " & c1
shp.Fill.Visible = msoFalse
Next c1
Next r1
End Sub
Sub SetTableColor(vip2 As Table, themeColor As MsoThemeColorIndex)
Dim r1 As Integer
Dim c1 As Integer
For c1 = 1 To vip2.Columns.Count
For r1 = 1 To vip2.Rows.Count
Dim Fill As Integer
vip2.Cell(r1, c1).Shape.Fill.ForeColor.ObjectThemeColor = themeColor
Next r1
Next c1
End Sub
Sub SetTableTexture(vip2 As Table, texture As MsoPresetTexture)
Dim r1 As Integer
Dim c1 As Integer
For c1 = 1 To vip2.Columns.Count
For r1 = 1 To vip2.Rows.Count
Dim Fill As Integer
vip2.Cell(r1, c1).Shape.Fill.PresetTextured(texture)
Next r1
Next c1
End Sub
Steps for creating Application
Step 1 : Start Microsoft PowerPoint 2010 :

Step 2 : Using Alt + F11 Key Start Visual Basic for Applications (VBA) Window :

Step 3 : Select on VBAProject(Presentation 1) :

Step 4 : Right Click On VBAProject(Presentation 1) ==> Goto Insert==> Goto Module & click on Module:


Step 5 : Write Code in Visual Basic for Applications (VBA) Window :

Step 6 : Run Application by using F8 again and again :
Step 7 : Macros window will open, Select Macros name and click on Run Button :

Step 8 : Output of Application :
There are three output of this application


