Use of PPT.Table.ApplyStyle in MS PowerPoint 2010 to Interact with Table Styles in VB.NET

In this article I am going to explain about how to Interact with Table Styles in a Microsoft PowerPoint 2010 presentation.
  • 5208

Introduction

In this article I am going to explain about how to Interact with Table Styles in a Microsoft PowerPoint 2010 presentation. For this we use PPT.Table.ApplyStyle in Microsoft PowerPoint 2010. Using PPT.Table.ApplyStyle we can Interact with Table Styles 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 program are given below

Sub TableStyleDemo() 

    Dim vip As Slide
    vip = ActivePresentation.Slides.Add(2, ppLayoutTable)
    vip.Select()
 
    Dim vip1 As Table
    vip1 = vip.Shapes.AddTable(4, 4).Table
    FillTable(vip1)
 
    With vip1.Cell(3, 3).Shape.TextFrame.TextRange
        .Font.Bold = msoTrue
        .Font.Size = 24

    End With
 
    vip1.ApplyStyle("{C083E6E3-FA7D-4D7B-A595-EF9225AFEA82}"True)
    Debug.Print("Style.Name: " & vip1.Style.Name)
    Debug.Print("Style.Id  : " & vip1.Style.Id)
 
    vip1.ApplyStyle("{46F890A9-2807-4EBB-B81D-B2AA78EC7F39}"False)
    Debug.Print("Style.Name: " & vip1.Style.Name)
    Debug.Print("Style.Id  : " & vip1.Style.Id)

End
 Sub
 
Sub
 FillTable(vip1 As Table)
 
    Dim row As Integer
    Dim col As Integer
 
    For col = 1 To vip1.Columns.Count
        vip1.Cell(1, col).Shape.TextFrame.TextRange.Text = "Heading " & col
    Next col
 
    For row = 2 To vip1.Rows.Count
        For col = 1 To vip1.Columns.Count
            vip1.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 : 

1.jpg

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

2.jpg

Step 3 : Select on VBAProject(Presentation 1) : 

3.jpg

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

4.jpg

5.jpg

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

 

Clipboard08.jpg

Step 6 : Run Application using F5 :

Step 7 : Macros window will open, Select Macros name and click on Run Button :

Clipboard02.jpg

Step 8:  Output of Application :

Clipboard04.jpg
 

Clipboard06.jpg

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.