PPT.TableProperties in MS PowerPoint 2010 to Set Banding and Scaling in VB.NET
In this article I am going to explain about how to set banding and scaling in a Microsoft PowerPoint 2010 presentation.
Introduction
In this article I am going to explain about how to set banding and scaling in a Microsoft PowerPoint 2010 presentation. For this we use PPT.TableProperties in Microsoft PowerPoint 2010. Using PPT.TableProperties we can use various settings to include banding and scaling 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 2010n
NOTE : OneNote 2010 is not a VBA host.
Code that we use in this application are given below
Sub TableProperties()
Dim pres As Presentation
pres = ActivePresentation
Dim sld As Slide
sld = pres.Slides.Add(2, ppLayoutTable)
sld.Select()
Dim tbl As Table
tbl = sld.Shapes.AddTable(4, 4).Table
FillTable(tbl)
' Variables to maintain the state:
Dim savedFirstRow As Boolean
Dim savedFirstCol As Boolean
Dim savedHorizBanding As Boolean
Dim savedLastCol As Boolean
Dim savedLastRow As Boolean
Dim savedVertBanding As Boolean
' Store the current state:
savedFirstRow = tbl.FirstRow
savedFirstCol = tbl.FirstCol
savedHorizBanding = tbl.HorizBanding
savedLastCol = tbl.LastCol
savedLastRow = tbl.LastRow
savedVertBanding = tbl.VertBanding
' Alter all settings:
tbl.HorizBanding = Not savedHorizBanding
tbl.VertBanding = Not savedVertBanding
tbl.FirstRow = Not savedFirstRow
tbl.FirstCol = Not savedFirstCol
tbl.LastCol = Not savedLastCol
tbl.LastRow = Not savedLastRow
' Scale the table to half size:
tbl.ScaleProportionally(0.5)
' Put it back the way it was (twice as big as it is currently):
tbl.ScaleProportionally(2)
' Put things back the way they were:
tbl.HorizBanding = savedHorizBanding
tbl.VertBanding = savedVertBanding
tbl.FirstRow = savedFirstRow
tbl.FirstCol = savedFirstCol
tbl.LastCol = savedLastCol
tbl.LastRow = savedLastRow
End Sub
Sub FillTable(tbl As Table)
' Fill a table with sample data.
Dim row As Integer
Dim col As Integer
For col = 1 To tbl.Columns.Count
tbl.Cell(1, col).Shape.TextFrame.TextRange.Text = "Heading " & col
Next col
For row = 2 To tbl.Rows.Count
For col = 1 To tbl.Columns.Count
tbl.Cell(row, col).Shape.TextFrame.TextRange.Text = "Cell " & row & ", " & col
Next col
Next row
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 using F8 :
Step 7 : Macros window will open, Select Macros name and click on Run Button :

Step 8 : Output of Application :



